FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-140550: Initial implementation of PEP 793 – PyModExport by encukou · Pull Request #140556 · python/cpython · GitHub

/ cpython Public

gh-140550: Initial implementation of PEP 793 – PyModExport - #140556

Merged
encukou merged 87 commits into
python:mainfrom
encukou:modexport-rebased
Nov 5, 2025
Merged

gh-140550: Initial implementation of PEP 793 – PyModExport#140556
encukou merged 87 commits into
python:mainfrom
encukou:modexport-rebased

Conversation

encukou commented Oct 24, 2025
edited
Loading

Copy link
Copy Markdown
Member

This adds the initial implementation of PEP-793.
See the issue for follow-up tasks.

encukou left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you for the initial review!

Yes, but there's a lot of tests. And I've also renamed things that changed semantics, so unrelated changes/backports will conflict or fail to build, rather than merge cleanly at the Git level but be subtly broken.

Comment on lines +1 to +2
import unittest
import types

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I couldn't find this in PEP 8.

Comment thread Lib/test/test_sys.py
Comment thread Objects/moduleobject.c
Comment thread Objects/moduleobject.c

encukou commented Oct 28, 2025

Copy link
Copy Markdown
Member Author

!buildbot AMD64.FreeBSD.Refleaks

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @encukou for commit 01d52ba 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F140556%2Fmerge

The command will test the builders whose names match following regular expression: AMD64.FreeBSD.Refleaks

The builders matched are:

  • AMD64 FreeBSD Refleaks PR

Comment thread Objects/moduleobject.c Outdated

encukou commented Oct 29, 2025

Copy link
Copy Markdown
Member Author

Do you plan to add documentation in a separated PR?

Yes. There's a lot to add since the PEP calls for soft-deprecation of PyInit_; see the issue.

Comment thread Include/internal/pycore_moduleobject.h Outdated
Comment thread Include/internal/pycore_moduleobject.h Outdated
Comment thread Include/internal/pycore_moduleobject.h Outdated
encukou and others added 2 commits November 3, 2025 14:52
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Comment thread Python/import.c Outdated

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM. Just please move _PyModule_GetGCHooks() to pycore_moduleobject.h.

Comment thread Include/internal/pycore_moduleobject.h Outdated
static inline PyModuleDef *_PyModule_GetDefOrNull(PyObject *arg) {
PyModuleObject *mod = _PyModule_CAST(arg);
if (mod->md_token_is_def) {
return (PyModuleDef *)((PyModuleObject *)mod)->md_token;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
return (PyModuleDef *)((PyModuleObject *)mod)->md_token;
return (PyModuleDef *)mod->md_token;

Comment thread Include/moduleobject.h Outdated

PyMODINIT_FUNC
FUNC_NAME(MODULE_NAME)(void)
INITFUNC_NAME(MODULE_NAME)(void)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is it really needed to define a PyInit function if a modexport function is defined with slots? Developers may reuse this code as an example.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for the catch! I think I had some platform-specific issues with the current version of setuptools. I added this to the TODO list in the issue; I'll get to it in a later PR.

Comment thread Objects/moduleobject.c Outdated

encukou commented Nov 5, 2025

Copy link
Copy Markdown
Member Author

Thank you for the review!

encukou merged commit 589a03a into python:main Nov 5, 2025
46 checks passed
encukou deleted the modexport-rebased branch November 5, 2025 11:31

vstinner commented Nov 5, 2025

Copy link
Copy Markdown
Member

Congrats :-)

vstinner commented Nov 5, 2025

Copy link
Copy Markdown
Member

make check-limited-abi does now fail on the main branch:

./python -E ./Tools/build/generate-build-details.py `cat pybuilddir.txt`/build-details.json
Checked 115 modules (37 built-in, 77 shared, 1 n/a on linux-x86_64, 0 disabled, 0 missing, 0 failed on import)
./python ./Tools/build/stable_abi.py --all
File /home/vstinner/python/main/Doc/data/stable_abi.dat differs from expected!
--- /home/vstinner/python/main/Doc/data/stable_abi.dat
+++ <expected>
@@ -979,14 +979,6 @@
 type,Py_buffer,3.11,,full-abi
 type,Py_intptr_t,3.2,,
 macro,Py_mod_abi,3.15,,
-macro,Py_mod_doc,3.15,,
-macro,Py_mod_methods,3.15,,
-macro,Py_mod_name,3.15,,
-macro,Py_mod_state_clear,3.15,,
-macro,Py_mod_state_free,3.15,,
-macro,Py_mod_state_size,3.15,,
-macro,Py_mod_state_traverse,3.15,,
-macro,Py_mod_token,3.15,,
 macro,Py_mp_ass_subscript,3.2,,
 macro,Py_mp_length,3.2,,
 macro,Py_mp_subscript,3.2,,

I created #141056 to fix the issue.

encukou commented Nov 5, 2025

Copy link
Copy Markdown
Member Author

Thank you!

StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
…honGH-140556)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL