summaryrefslogtreecommitdiffstats
path: root/Doc/c-api
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-11-05 13:35:56 (GMT)
committerGitHub <noreply@github.com>2019-11-05 13:35:56 (GMT)
commit1270d2cf1d17bfa581bf2a19f82c8cb43bf793d9 (patch)
treebf32cada273d51fd0123a10983ff3927f26678e8 /Doc/c-api
parent0eb6fefad7c753a186cf51f0dc52416a1a8d6d51 (diff)
downloadcpython-1270d2cf1d17bfa581bf2a19f82c8cb43bf793d9.zip
cpython-1270d2cf1d17bfa581bf2a19f82c8cb43bf793d9.tar.gz
cpython-1270d2cf1d17bfa581bf2a19f82c8cb43bf793d9.tar.bz2
[3.8] bpo-38159: Clarify documentation of PyState_AddModule (GH-16101) (GH-17026)
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 <encukou@gmail.com> https://bugs.python.org/issue38159 Automerge-Triggered-By: @encukou
Diffstat (limited to 'Doc/c-api')
-rw-r--r--Doc/c-api/module.rst11
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