8000 PEP 793: Two small updates by encukou · Pull Request #4472 · python/peps · GitHub
[go: up one dir, main page]

Skip to content

PEP 793: Two smal 8000 l updates #4472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.)
  • Loading branch information
encukou committed Jun 24, 2025
commit a161045494ddade6ce30162b5f45d6ebbe568e10
14 changes: 8 additions & 6 deletions peps/pep-0793.rst
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,15 @@ will return 0 on success and -1 on failure:

A new ``PyType_GetModuleByToken`` function will be added, with a signature
like the existing ``PyType_GetModuleByDef`` but a ``void *token`` argument,
and the same behaviour except matching tokens rather than only defs.
and the same behaviour except matching tokens rather than only defs,
and returning a strong reference.

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

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