gh-101944: Clarify PyModule_AddObjectRef() documentation (#129433)

This commit is contained in:
Victor Stinner 2025-02-03 12:55:22 +01:00 committed by GitHub
parent 39b754a359
commit 04264a286e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -523,9 +523,6 @@ state:
On success, return ``0``. On error, raise an exception and return ``-1``. 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:: Example usage::
static int static int
@ -540,6 +537,10 @@ state:
return res; 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 The example can also be written without checking explicitly if *obj* is
``NULL``:: ``NULL``::