From a7645468c2ef356599299789a5105706f38c8b0e Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Mon, 3 Feb 2025 13:02:31 +0100 Subject: [PATCH] [3.12] gh-101944: Clarify PyModule_AddObjectRef() documentation (GH-129433) (#129613) gh-101944: Clarify PyModule_AddObjectRef() documentation (GH-129433) (cherry picked from commit 04264a286e5ddfe8ac7423f7376ca34a2ca8b7ba) Co-authored-by: Victor Stinner --- Doc/c-api/module.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst index cfa6a1a98524..b110443d9270 100644 --- a/Doc/c-api/module.rst +++ b/Doc/c-api/module.rst @@ -496,9 +496,6 @@ state: On success, return ``0``. On error, raise an exception and return ``-1``. - Return ``-1`` if *value* is ``NULL``. It must be called with an exception - raised in this case. - Example usage:: static int @@ -513,6 +510,10 @@ state: return res; } + To be convenient, the function accepts ``NULL`` *value* with an exception + set. In this case, return ``-1`` and just leave the raised exception + unchanged. + The example can also be written without checking explicitly if *obj* is ``NULL``:: -- 2.47.3