]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38159: Clarify documentation of PyState_AddModule (GH-16101)
authorPetr Viktorin <encukou@gmail.com>
Fri, 1 Nov 2019 15:47:05 +0000 (16:47 +0100)
committerGitHub <noreply@github.com>
Fri, 1 Nov 2019 15:47:05 +0000 (16:47 +0100)
This was never intented to be called manually from PyInit_*.

Also, clarify PyState_RemoveModule return value.

Doc/c-api/module.rst

index 46306b3917cce078497f736d073fc6c200a1e310..57902a9c7f8384784c96f0779213ad0e40efdea0 100644 (file)
@@ -485,10 +485,21 @@ since multiple such modules can be created from a single definition.
 
    Only effective on modules created using single-phase initialization.
 
+   Python calls ``PyState_AddModule`` automatically after importing a module,
+   so it is unnecessary (but harmless) to call it from module initialization
+   code. An explicit call is needed only if the module's own init code
+   subsequently calls ``PyState_FindModule``.
+   The function is mainly intended for implementing alternative import
+   mechanisms (either by calling it directly, or by referring to its
+   implementation for details of the required state updates).
+
+   Return 0 on success or -1 on failure.
+
    .. versionadded:: 3.3
 
 .. c:function:: int PyState_RemoveModule(PyModuleDef *def)
 
    Removes the module object created from *def* from the interpreter state.
+   Return 0 on success or -1 on failure.
 
    .. versionadded:: 3.3