Skip to content

Commit

Permalink
[3.8] bpo-38159: Clarify documentation of PyState_AddModule (GH-16101) (
Browse files Browse the repository at this point in the history
GH-17026)

This was never intented to be called manually from PyInit_*.

Also, clarify PyState_RemoveModule return value.
(cherry picked from commit 9bc94ec)


Co-authored-by: Petr Viktorin <encukou@gmail.com>


https://bugs.python.org/issue38159



Automerge-Triggered-By: @encukou
  • Loading branch information
miss-islington committed Nov 5, 2019
1 parent 0eb6fef commit 1270d2c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Doc/c-api/module.rst
Expand Up @@ -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

0 comments on commit 1270d2c

Please sign in to comment.