From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 3 Feb 2025 12:02:00 +0000 (+0100) Subject: [3.13] gh-101944: Clarify PyModule_AddObjectRef() documentation (GH-129433) (#129612) X-Git-Tag: v3.13.2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=186165e509c056657cd9ec058cbc1e76f9f50910;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-101944: Clarify PyModule_AddObjectRef() documentation (GH-129433) (#129612) 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 f82a050ab75d..f71089370152 100644 --- a/Doc/c-api/module.rst +++ b/Doc/c-api/module.rst @@ -523,9 +523,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 @@ -540,6 +537,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``::