Skip to content

Raise an error when importing modules compiled for an older Python#139

Merged
befeleme merged 1 commit intofedora-python:fedora-3.14from
befeleme:disallow-running-update
Feb 9, 2026
Merged

Raise an error when importing modules compiled for an older Python#139
befeleme merged 1 commit intofedora-python:fedora-3.14from
befeleme:disallow-running-update

Conversation

@befeleme
Copy link

@befeleme befeleme commented Feb 6, 2026

This is a downstream workaround for
python#128341 -
it is resolved for Python 3.15+, but the issue happened again in the update from 3.14.2 to 3.14.3 (segfault when importing _pickle).

@befeleme befeleme force-pushed the disallow-running-update branch from 28a5464 to 9dc0ede Compare February 6, 2026 09:57
@hroncok
Copy link
Member

hroncok commented Feb 6, 2026

[root@216b304ef039 /]# for module in /usr/lib64/python3.14/lib-dynload/*.so; do strings $module | grep -qF 'internal Python C API version mismatch' || echo $module BAD; done
/usr/lib64/python3.14/lib-dynload/_posixshmem.cpython-314-x86_64-linux-gnu.so BAD
/usr/lib64/python3.14/lib-dynload/_statistics.cpython-314-x86_64-linux-gnu.so BAD
/usr/lib64/python3.14/lib-dynload/_uuid.cpython-314-x86_64-linux-gnu.so BAD
/usr/lib64/python3.14/lib-dynload/fcntl.cpython-314-x86_64-linux-gnu.so BAD
/usr/lib64/python3.14/lib-dynload/termios.cpython-314-x86_64-linux-gnu.so BAD

@befeleme befeleme force-pushed the disallow-running-update branch from 9dc0ede to 0505ac8 Compare February 6, 2026 15:16
@befeleme befeleme force-pushed the disallow-running-update branch 2 times, most recently from bc8e27a to 54a4259 Compare February 9, 2026 09:52
@befeleme
Copy link
Author

befeleme commented Feb 9, 2026

[root@216b304ef039 /]# for module in /usr/lib64/python3.14/lib-dynload/*.so; do strings $module | grep -qF 'internal Python C API version mismatch' || echo $module BAD; done
/usr/lib64/python3.14/lib-dynload/_posixshmem.cpython-314-x86_64-linux-gnu.so BAD
/usr/lib64/python3.14/lib-dynload/_statistics.cpython-314-x86_64-linux-gnu.so BAD
/usr/lib64/python3.14/lib-dynload/_uuid.cpython-314-x86_64-linux-gnu.so BAD
/usr/lib64/python3.14/lib-dynload/fcntl.cpython-314-x86_64-linux-gnu.so BAD
/usr/lib64/python3.14/lib-dynload/termios.cpython-314-x86_64-linux-gnu.so BAD

All five of them contain:

#ifndef Py_GIL_DISABLED
#  define Py_LIMITED_API 0x030d0000
#endif

hence use stable ABI.

@befeleme befeleme force-pushed the disallow-running-update branch 2 times, most recently from 457ecc7 to 73b4b0b Compare February 9, 2026 12:28
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.

All five of them contain (...) hence use stable ABI.

In this case, they are not affected by the issue python#128341 and we are good.

@befeleme befeleme force-pushed the disallow-running-update branch from 73b4b0b to 70108fb Compare February 9, 2026 15:40
…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.

_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 branch from 70108fb to d3057db Compare February 9, 2026 15:49
@befeleme befeleme merged commit 8c71d69 into fedora-python:fedora-3.14 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