Skip to content

Conversation

@encukou
Copy link
Member

@encukouencukou commented Oct 24, 2025

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

Copy link
MemberAuthor

@encukouencukou 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
MemberAuthor

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
MemberAuthor

!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
MemberAuthor

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.

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

@vstinnervstinner 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.

staticinlinePyModuleDef*_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
MemberAuthor

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
MemberAuthor

Thank you for the review!

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

Congrats :-)

@vstinner
Copy link
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
Copy link
MemberAuthor

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>
Sign up for freeto 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

@encukou@bedevere-bot@vstinner@kumaraditya303