From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 3 Feb 2025 12:02:31 +0000 (+0100) Subject: [3.12] gh-101944: Clarify PyModule_AddObjectRef() documentation (GH-129433) (#129613) X-Git-Tag: v3.12.9~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a7645468c2ef356599299789a5105706f38c8b0e;p=thirdparty%2FPython%2Fcpython.git [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 --- 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``::