From: Victor Stinner Date: Mon, 3 Feb 2025 11:55:22 +0000 (+0100) Subject: gh-101944: Clarify PyModule_AddObjectRef() documentation (#129433) X-Git-Tag: v3.14.0a5~123 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=04264a286e5ddfe8ac7423f7376ca34a2ca8b7ba;p=thirdparty%2FPython%2Fcpython.git gh-101944: Clarify PyModule_AddObjectRef() documentation (#129433) --- 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``::