Skip to content

Commit a161045

Browse files
committed
PEP 793: Two small updates
- PyType_GetModuleByToken will return a strong reference, unlike PyType_GetModuleByDef - Remove incorrect note that the new API creates modules from a *spec*. (The note could be updated to say *slots*, but, it isn't that important.)
1 parent 01303cb commit a161045

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

peps/pep-0793.rst

Lines changed: 8 additions & 6 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

@@ -346,8 +349,7 @@ They may not have a ``NULL`` value (instead, the slot can be omitted entirely).
346349
Note that currently, for modules created from a *spec* (that is, using
347350
``PyModule_FromDefAndSpec``), the ``PyModuleDef.m_name`` member is ignored
348351
and the name from the spec is used instead.
349-
All API proposed in this document creates modules from a *spec*, and it will
350-
ignore ``Py_mod_name`` in the same way.
352+
All API proposed in this document will ignore ``Py_mod_name`` in the same way.
351353
The slot will be optional, but extension authors are strongly encouraged to
352354
include it for the benefit of future APIs, external tooling, debugging,
353355
and introspection.

0 commit comments

Comments
 (0)