Skip to content

Conversation

@befeleme
Copy link

@befeleme befeleme commented Feb 9, 2026

I was git grepping Modules with git grep -L "PyModuleDef_Init" -- 'Modules/*.c' and compared results, finding _cursesmodule to patch additionally in 3.13 -- the patch can't be taken "as is" from the 3.14 branch. Will appreciate another pair of eyes of the modules list.

@befeleme befeleme force-pushed the disallow-running-update-313 branch 2 times, most recently from 7fce2e7 to ddba252 Compare February 9, 2026 12:25
@befeleme
Copy link
Author

befeleme commented Feb 9, 2026

for module in usr/lib64/python3.13/lib-dynload/*.so; do strings $module | grep -qF 'internal Python C API version mismatch' || echo $module BAD; done
usr/lib64/python3.13/lib-dynload/_contextvars.cpython-313-x86_64-linux-gnu.so BAD
usr/lib64/python3.13/lib-dynload/fcntl.cpython-313-x86_64-linux-gnu.so BAD
usr/lib64/python3.13/lib-dynload/_posixshmem.cpython-313-x86_64-linux-gnu.so BAD
usr/lib64/python3.13/lib-dynload/_statistics.cpython-313-x86_64-linux-gnu.so BAD
usr/lib64/python3.13/lib-dynload/termios.cpython-313-x86_64-linux-gnu.so BAD
usr/lib64/python3.13/lib-dynload/_uuid.cpython-313-x86_64-linux-gnu.so BAD

_contextvars is different from the rest, and only in 3.13: it uses PyModuleDef_Init and there's no reference to Py_LIMITED_API. I don't know what to take from this.

@befeleme
Copy link
Author

befeleme commented Feb 9, 2026

I've tested a scratchbuild from https://koji.fedoraproject.org/koji/taskinfo?taskID=142118107 in a container and as to the on-the-fly update scenario it seems to work correctly.

@hroncok
Copy link
Member

hroncok commented Feb 9, 2026

_contextvars is different from the rest, and only in 3.13: it uses PyModuleDef_Init and there's no reference to Py_LIMITED_API. I don't know what to take from this.

Possibly it doesn't use Py_BUILD_CORE?

@befeleme
Copy link
Author

befeleme commented Feb 9, 2026

_contextvars is different from the rest, and only in 3.13: it uses PyModuleDef_Init and there's no reference to Py_LIMITED_API. I don't know what to take from this.

Possibly it doesn't use Py_BUILD_CORE?

Ah, yes. It indeed doesn't.

@befeleme befeleme force-pushed the disallow-running-update-313 branch from ddba252 to 6176ab6 Compare February 9, 2026 15:40
@vstinner
Copy link

vstinner commented Feb 9, 2026

The issue mostly comes from the usage of _Py_ID() calls, but Modules/_contextvarsmodule.c and Modules/clinic/_contextvarsmodule.c.h don't use _Py_ID() and so it should not crash on Python upgrade.

…fferent Python version

This is a downstream workaround "implementing" python#137212 -
the mechanism for the check exists in Python 3.15+, where it needs to be
added to the standard library modules.
In Fedora, we need it also in previous Python versions, as we experience
segmentation fault when importing stdlib modules after update while
Python is running.

_curses, _tkinter, _tracemalloc and readline are not calling PyModuleDef_Init,
which is modified with this patch, hence they need a
direct call to the check function.

Co-Authored-By: Karolina Surma <ksurma@redhat.com>
@befeleme befeleme force-pushed the disallow-running-update-313 branch from 6176ab6 to d1f8902 Compare February 9, 2026 15:49
Copy link

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

Extensions using PyModule_Create() are modified to call _PyHack_CheckInternalAPIVersion(). Test extensions (using PyModule_Create()) are not modified, but I don't think that we should fix them.

@befeleme befeleme merged commit 53f1c41 into fedora-python:fedora-3.13 Feb 9, 2026
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