Skip to content

Conversation

@encukou
Copy link
Member

@encukou encukou commented Oct 24, 2025

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

encukou and others added 2 commits October 28, 2025 18:30
Co-Authored-By: Victor Stinner <vstinner@python.org>
Copy link
Member Author

@encukou encukou left a comment

Choose a reason for hiding this comment

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

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
Member Author

Choose a reason for hiding this comment

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

I couldn't find this in PEP 8.

@encukou
Copy link
Member Author

encukou commented Oct 28, 2025

!buildbot AMD64.FreeBSD.Refleaks

@bedevere-bot
Copy link

🤖 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

@encukou
Copy link
Member Author

encukou commented Oct 29, 2025

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.

encukou and others added 2 commits November 3, 2025 14:52
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

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

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
Member

Choose a reason for hiding this comment

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

Suggested change
return (PyModuleDef *)((PyModuleObject *)mod)->md_token;
return (PyModuleDef *)mod->md_token;


PyMODINIT_FUNC
FUNC_NAME(MODULE_NAME)(void)
INITFUNC_NAME(MODULE_NAME)(void)
Copy link
Member

Choose a reason for hiding this comment

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

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
Member Author

Choose a reason for hiding this comment

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

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.

@encukou
Copy link
Member Author

encukou commented Nov 5, 2025

Thank you for the review!

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

vstinner commented Nov 5, 2025

Congrats :-)

@vstinner
Copy link
Member

vstinner commented Nov 5, 2025

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
Copy link
Member Author

encukou commented Nov 5, 2025

Thank you!

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