From 4342af00d87de0a0d0ef3bfda4d6edb08ac2427a Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Tue, 5 Nov 2019 05:36:09 -0800 Subject: [PATCH] [3.7] bpo-38159: Clarify documentation of PyState_AddModule (GH-16101) (GH-17027) This was never intented to be called manually from PyInit_*. Also, clarify PyState_RemoveModule return value. (cherry picked from commit 9bc94eca0c69a551f928692364a99e9b67c4a45b) Co-authored-by: Petr Viktorin https://bugs.python.org/issue38159 Automerge-Triggered-By: @encukou --- Doc/c-api/module.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst index 60c1bf48c60c..a06e791e38f2 100644 --- a/Doc/c-api/module.rst +++ b/Doc/c-api/module.rst @@ -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 -- 2.47.3