From 45e9343d7eed1d9e784e731cc9af853fa8649e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 4 Mar 2026 13:59:50 +0100 Subject: [PATCH 1/4] GH-144739: Skip test_pyexpat.MemoryProtectionTest based on expat compile-time version, not runtime (#144740) --- Lib/test/test_pyexpat.py | 4 +++- .../next/Tests/2026-02-12-12-12-00.gh-issue-144739.-fx1tN.rst | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Tests/2026-02-12-12-12-00.gh-issue-144739.-fx1tN.rst diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py index 74a75458289b4d..31bcee293b2b69 100644 --- a/Lib/test/test_pyexpat.py +++ b/Lib/test/test_pyexpat.py @@ -1069,7 +1069,9 @@ def test_set_maximum_amplification__amplification_not_exceeded(self): self.assertIsNotNone(parser.Parse(payload, True)) -@unittest.skipIf(expat.version_info < (2, 7, 2), "requires Expat >= 2.7.2") +@unittest.skipIf(not hasattr(expat.XMLParserType, + "SetAllocTrackerMaximumAmplification"), + "requires Python compiled with Expat >= 2.7.2") class MemoryProtectionTest(AttackProtectionTestBase, unittest.TestCase): # NOTE: with the default Expat configuration, the billion laughs protection diff --git a/Misc/NEWS.d/next/Tests/2026-02-12-12-12-00.gh-issue-144739.-fx1tN.rst b/Misc/NEWS.d/next/Tests/2026-02-12-12-12-00.gh-issue-144739.-fx1tN.rst new file mode 100644 index 00000000000000..8c46ff133f9433 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-02-12-12-12-00.gh-issue-144739.-fx1tN.rst @@ -0,0 +1,3 @@ +When Python was compiled with system expat older then 2.7.2 but tests run +with newer expat, still skip +:class:`!test.test_pyexpat.MemoryProtectionTest`. From 3fe7849d9a50075901195602bb7143b93537289a Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Wed, 4 Mar 2026 14:21:10 +0100 Subject: [PATCH 2/4] gh-145376: Fix refleak in error path of time_tzset (GH-145477) --- Modules/timemodule.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 3946d18479e253..a3260e0f15ab99 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -1170,7 +1170,8 @@ time_tzset(PyObject *self, PyObject *unused) /* Reset timezone, altzone, daylight and tzname */ if (init_timezone(m) < 0) { - return NULL; + Py_DECREF(m); + return NULL; } Py_DECREF(m); if (PyErr_Occurred()) From f9dac4e2ebbb913479bf882f0ac582040ba54ea3 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Wed, 4 Mar 2026 14:32:14 +0100 Subject: [PATCH 3/4] gh-145376: Avoid reference leaks in failure path of _functoolsmodule.c method partial_new (GH-145423) --- Modules/_functoolsmodule.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 5286be0b715fff..336a2e57ec0179 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -252,6 +252,11 @@ partial_new(PyTypeObject *type, PyObject *args, PyObject *kw) } PyObject *item; PyObject *tot_args = PyTuple_New(tot_nargs); + if (tot_args == NULL) { + Py_DECREF(new_args); + Py_DECREF(pto); + return NULL; + } for (Py_ssize_t i = 0, j = 0; i < tot_nargs; i++) { if (i < npargs) { item = PyTuple_GET_ITEM(pto_args, i); From 18aec59fe5bbae9225951ca4d69bfca17eba82d8 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Wed, 4 Mar 2026 14:34:24 +0100 Subject: [PATCH 4/4] gh-145376: Fix refleak in unusual error path in BaseExceptionGroup_new (GH-145474) --- Objects/exceptions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 499fb2b34b34a8..f5edc286243ee1 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -912,7 +912,7 @@ BaseExceptionGroup_new(PyTypeObject *type, PyObject *args, PyObject *kwds) exceptions = PySequence_Tuple(exceptions); if (!exceptions) { - return NULL; + goto error; } /* We are now holding a ref to the exceptions tuple */