From dabf0f20e735b788dca58c5aa6494e27db44cc9f Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 3 Feb 2025 12:55:22 +0100 Subject: [PATCH] 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 cfa6a1a985245e..b110443d927070 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``::