Update to Python 3.14.3

This commit is contained in:
Karolina Surma 2026-02-09 10:10:12 +01:00
commit 406c34b53b
5 changed files with 187 additions and 16 deletions

View file

@ -41,7 +41,7 @@ index 5c10bcedc6..1fd7a273b5 100644
result = BytesIO()
xmlgen = XMLGenerator(result)
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 25c084c8b9..e26e6e0c26 100644
index 0b343cc4bb..145ecacd21 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -1573,9 +1573,13 @@ def test_simple_xml(self, chunk_size=None, flush=False):

View file

@ -0,0 +1,156 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <encukou@gmail.com>
Date: Fri, 6 Feb 2026 10:51:02 +0100
Subject: 00477: Raise an error when importing stdlib modules compiled for a
different Python version
This is a downstream workaround "implementing"
https://github.com/python/cpython/pull/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>
---
Include/moduleobject.h | 43 ++++++++++++++++++++++++++++++++++++++++++
Makefile.pre.in | 3 +++
Modules/_tkinter.c | 6 ++++++
Modules/_tracemalloc.c | 6 ++++++
Modules/readline.c | 6 ++++++
Objects/moduleobject.c | 1 +
6 files changed, 65 insertions(+)
diff --git a/Include/moduleobject.h b/Include/moduleobject.h
index 2a17c891dd..64017c666c 100644
--- a/Include/moduleobject.h
+++ b/Include/moduleobject.h
@@ -116,6 +116,49 @@ struct PyModuleDef {
freefunc m_free;
};
+#if defined(_PyHack_check_version_on_modinit) && defined(Py_BUILD_CORE)
+/* The mechanism for the check has been implemented on Python 3.15+:
+ * https://github.com/python/cpython/pull/137212.
+ * In Fedora, we need this in older Pythons too:
+ * if somebody attempts to import a module compiled for a different Python version,
+ * instead of segmentation fault a meaningful error is raised.
+ */
+PyAPI_DATA(const unsigned long) Py_Version;
+
+static inline int
+_PyHack_CheckInternalAPIVersion(const char *mod_name)
+{
+ if (PY_VERSION_HEX != Py_Version) {
+ PyErr_Format(
+ PyExc_ImportError,
+ "internal Python C API version mismatch: "
+ "module %s compiled with %lu.%lu.%lu; "
+ "runtime version is %lu.%lu.%lu",
+ mod_name,
+ (const unsigned long)((PY_VERSION_HEX >> 24) & 0xFF),
+ (const unsigned long)((PY_VERSION_HEX >> 16) & 0xFF),
+ (const unsigned long)((PY_VERSION_HEX >> 8) & 0xFF),
+ (const unsigned long)((Py_Version >> 24) & 0xFF),
+ (const unsigned long)((Py_Version >> 16) & 0xFF),
+ (const unsigned long)((Py_Version >> 8) & 0xFF)
+ );
+ return -1;
+ }
+ return 0;
+}
+
+static inline PyObject *
+PyModuleDef_Init_with_check(PyModuleDef *def)
+{
+ if (_PyHack_CheckInternalAPIVersion(def->m_name) < 0) {
+ return NULL;
+ }
+ return PyModuleDef_Init(def);
+}
+
+#define PyModuleDef_Init PyModuleDef_Init_with_check
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 38a355a23f..67c19c329e 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -3415,3 +3415,6 @@ MODULE__MULTIBYTECODEC_DEPS=$(srcdir)/Modules/cjkcodecs/multibytecodec.h
# Local Variables:
# mode: makefile
# End:
+
+# Fedora-specific, downstream only
+PY_STDMODULE_CFLAGS += -D_PyHack_check_version_on_modinit=1
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 2216de509e..a640496f7f 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -3489,6 +3489,12 @@ static struct PyModuleDef _tkintermodule = {
PyMODINIT_FUNC
PyInit__tkinter(void)
{
+ #ifdef _PyHack_check_version_on_modinit
+ if (_PyHack_CheckInternalAPIVersion("_tkinter") < 0) {
+ return NULL;
+ }
+ #endif
+
PyObject *m, *uexe, *cexe;
tcl_lock = PyThread_allocate_lock();
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c
index be71fc9fc9..67922098b2 100644
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -215,6 +215,12 @@ static struct PyModuleDef module_def = {
PyMODINIT_FUNC
PyInit__tracemalloc(void)
{
+ #ifdef _PyHack_check_version_on_modinit
+ if (_PyHack_CheckInternalAPIVersion("_tracemalloc") < 0) {
+ return NULL;
+ }
+ #endif
+
PyObject *mod = PyModule_Create(&module_def);
if (mod == NULL) {
return NULL;
diff --git a/Modules/readline.c b/Modules/readline.c
index 8475846eef..b3f5eb3a1f 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -1604,6 +1604,12 @@ static struct PyModuleDef readlinemodule = {
PyMODINIT_FUNC
PyInit_readline(void)
{
+ #ifdef _PyHack_check_version_on_modinit
+ if (_PyHack_CheckInternalAPIVersion("readline") < 0) {
+ return NULL;
+ }
+ #endif
+
const char *backend = "readline";
PyObject *m;
readlinestate *mod_state;
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index b68584b5dd..cbf95dc92a 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -50,6 +50,7 @@ _PyModule_IsExtension(PyObject *obj)
}
+#undef PyModuleDef_Init
PyObject*
PyModuleDef_Init(PyModuleDef* def)
{

View file

@ -24,19 +24,18 @@ discover:
test: "PYTHON=python${pybasever}d TOX=false VERSION=${pybasever} CYTHON=true ./venv.sh"
- name: selftest
path: /selftest
test: "VERSION=${pybasever} X='-i test_check_probes -i test_margin_is_sufficient' ./parallel.sh"
test: "VERSION=${pybasever} X='-i test_check_probes' ./parallel.sh"
- name: debugtest
path: /selftest
# test_base_interpreter: https://github.com/python/cpython/issues/131372
# test_margin_is_sufficient: https://github.com/python/cpython/issues/140222
test: "VERSION=${pybasever} PYTHON=python${pybasever}d X='-i test_check_probes -i test_base_interpreter -i test_margin_is_sufficient' ./parallel.sh"
test: "VERSION=${pybasever} PYTHON=python${pybasever}d X='-i test_check_probes -i test_base_interpreter' ./parallel.sh"
- name: freethreadingtest
path: /selftest
test: "VERSION=${pybasever}t X='-i test_check_probes -i test_base_interpreter -i test_margin_is_sufficient' ./parallel.sh"
test: "VERSION=${pybasever}t X='-i test_check_probes -i test_base_interpreter' ./parallel.sh"
- name: selftest_jit
path: /selftest
# test_attr_promotion_failure: https://github.com/python/cpython/issues/141833
test: "VERSION=${pybasever} PYTHON_JIT=1 X='-i test_check_probes -i test_attr_promotion_failure -i test_margin_is_sufficient' ./parallel.sh"
test: "VERSION=${pybasever} PYTHON_JIT=1 X='-i test_check_probes -i test_attr_promotion_failure' ./parallel.sh"
- name: jit_disabled_by_default
test: "python${pybasever} -c 'import sys; assert not sys._jit.is_enabled()'"
- name: jit_disabled_explicitly

View file

@ -45,11 +45,11 @@ URL: https://www.python.org/
# WARNING When rebasing to a new Python version,
# remember to update the python3-docs package as well
%global general_version %{pybasever}.2
%global general_version %{pybasever}.3
#global prerel ...
%global upstream_version %{general_version}%{?prerel}
Version: %{general_version}%{?prerel:~%{prerel}}
Release: 3%{?dist}
Release: 1%{?dist}
License: Python-2.0.1
@ -416,6 +416,22 @@ Patch464: 00464-enable-pac-and-bti-protections-for-aarch64.patch
# which is tested as working.
Patch466: 00466-downstream-only-skip-tests-not-working-with-older-expat-version.patch
# 00477 # f9f53e560d161531a0c3476c08ee26b89a628bde
# Raise an error when importing stdlib modules compiled for a different Python version
#
# This is a downstream workaround "implementing"
# https://github.com/python/cpython/pull/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.
Patch477: 00477-raise-an-error-when-importing-stdlib-modules-compiled-for-a-different-python-version.patch
# (New patches go here ^^^)
#
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
@ -1472,8 +1488,6 @@ CheckPython() {
# test_check_probes is failing since it was introduced in 3.12.0rc1,
# the test is skipped until it is fixed in upstream.
# see: https://github.com/python/cpython/issues/104280#issuecomment-1669249980
# test_margin_is_sufficient
# reported in https://github.com/python/cpython/issues/140222
LD_LIBRARY_PATH=$ConfDir $ConfDir/python -m test.regrtest \
-wW --slowest %{_smp_mflags} \
%ifarch riscv64
@ -1482,7 +1496,6 @@ CheckPython() {
--timeout=2700 \
%endif
-i test_check_probes \
-i test_margin_is_sufficient \
echo FINISHED: CHECKING OF PYTHON FOR CONFIGURATION: $ConfName
@ -1972,6 +1985,9 @@ CheckPython freethreading
# ======================================================
%changelog
* Wed Feb 04 2026 Karolina Surma <ksurma@redhat.com> - 3.14.3-1
- Update to Python 3.14.3
* Sat Jan 17 2026 Fedora Release Engineering <releng@fedoraproject.org> - 3.14.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild

10
sources
View file

@ -1,5 +1,5 @@
SHA512 (Python-3.14.2.tar.xz) = 165256b4c713e0262767cd7a2c65622f3f086423524646a39bfa64912376be9e5b70863d5a3c95224b516152d0b79e7ccbfe2f2cf35b809d132f2c38ebb3ab3b
SHA512 (Python-3.14.2-aarch64-debug-jit_stencils.h) = c4d14860576768e24d15b9b1c8fbb9878403710126188e39265726fefcfe7336339bc863320a79b535516669101e7486051f37c0e797857adbc60073ed340ac1
SHA512 (Python-3.14.2-aarch64-optimized-jit_stencils.h) = 64a23be3f2bd1e45b487d9e9e9010c3caa08ca2102d733ab54031c6fca5bcd6881b34ce9c6cc3cab58fd640f7b3af24d32ac828ee1fd3f44edbc276c98dd1596
SHA512 (Python-3.14.2-x86_64-debug-jit_stencils.h) = 25e9a7e5867fa4c91d95c82dc63aeea19072a82a1bffe402554cf4abf7569c7510ab72815bb1c9ff7a4303192d65082f6d97bb5a334968ee7c06a360d9dac2cd
SHA512 (Python-3.14.2-x86_64-optimized-jit_stencils.h) = 52182daa5c50c60cc649a391a80f27e69e0eb86b5327c15a0af37657095e3e72916290106bd7dc640d5c5fdb71ad8c492a24ba4fa73411fd0b4ed248c75d3a81
SHA512 (Python-3.14.3.tar.xz) = 9fd875f7a1d96d64e7150913ef38b72b0aeecfcbc24ba46967e57b6495146b0cba6b940c273561fc4d656b6d0ce2e23ffb7bd32bcd0b61fd59a6d90585998c07
SHA512 (Python-3.14.3-aarch64-debug-jit_stencils.h) = 31cd37ee2c788e63867deb3cc40d34be3100a191dbc42a41c30b1de5e23c5dff2aa27e6927baaf2d0a220f32079c5c650b10f72d79939975845c3977508fd4b1
SHA512 (Python-3.14.3-aarch64-optimized-jit_stencils.h) = 504af12fda768c819954367ccb3cdd5af45a473bd311d1b884ef54263248c036cd6722dada013bc060231274c9bfaa20c65958cf4f546e363fe0a8b9ec0e4a93
SHA512 (Python-3.14.3-x86_64-debug-jit_stencils.h) = 0a4a5ba7a48177c0ee66f9eb5215b0287a28d7b0c1943d6a2590921f5e12507eea041f43985c4321d6bf9a2573f70d94c15ef5fee0df2227af1fd45f09409552
SHA512 (Python-3.14.3-x86_64-optimized-jit_stencils.h) = f9e126f66a8c7650ea26c92e4190dee613c5b899dd231ee8d43173e040f29a217d0298675f7ec75df37da340b39af9fc21a7e1711722876ad5830e52b517baea