8000 PEP 793: PyType_GetModuleByToken will return a strong reference (GH-4… · python/peps@65602dc · GitHub
[go: up one dir, main page]

Skip to content

Commit 65602dc

Browse files
authored
PEP 793: PyType_GetModuleByToken will return a strong reference (GH-4472)
PyType_GetModuleByToken will return a strong reference, unlike PyType_GetModuleByDef
1 parent 01303cb commit 65602dc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

peps/pep-0793.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,15 @@ will return 0 on success and -1 on failure:
318318
319319
A new ``PyType_GetModuleByToken`` function will be added, with a signature
320320
like the existing ``PyType_GetModuleByDef`` but a ``void *token`` argument,
321-
and the same behaviour except matching tokens rather than only defs.
321+
and the same behaviour except matching tokens rather than only defs,
322+
and returning a strong reference.
322323

323324
For easier backwards compatibility, the existing ``PyType_GetModuleByDef``
324-
will be changed to work exactly like ``PyType_GetModuleByToken`` -- that is,
325-
it will allow a token (cast to a ``PyModuleDef *`` pointer) as the
326-
*def* argument.
325+
will be changed to also allow a token (cast to a ``PyModuleDef *`` pointer) as
326+
the *def* argument.
327+
That is, ``PyType_GetModuleByToken`` and ``PyType_GetModuleByDef`` will differ
328+
only in the formal signature of the second argument and by returning a
329+
borrowed vs. strong reference.
327330
(The ``PyModule_GetDef`` function will not get a similar change, as users may
328331
access members of its result.)
329332

0 commit comments

Comments
 (0)
0