diff options
author | Petr Viktorin <encukou@gmail.com> | 2019-11-01 15:47:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-01 15:47:05 (GMT) |
commit | 9bc94eca0c69a551f928692364a99e9b67c4a45b (patch) | |
tree | 3171128cf7acb0f275177ee6a58cf2a046d9a8ab | |
parent | 112f2b805bc83429e8a66a54d088bbefc921abb7 (diff) | |
download | cpython-9bc94eca0c69a551f928692364a99e9b67c4a45b.zip cpython-9bc94eca0c69a551f928692364a99e9b67c4a45b.tar.gz cpython-9bc94eca0c69a551f928692364a99e9b67c4a45b.tar.bz2 |
bpo-38159: Clarify documentation of PyState_AddModule (GH-16101)
This was never intented to be called manually from PyInit_*.
Also, clarify PyState_RemoveModule return value.
-rw-r--r-- | Doc/c-api/module.rst | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst index 46306b3..57902a9 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 |