From ff8ae302f0ebcf5839603bb53829cfef4a7825b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 11 Aug 2026 13:06:45 +0200 Subject: [PATCH 1/3] gh-155485: Skip test_subparser_inherits_reparse_deferral with Expat < 2.6.0 The test was added in 7d760134cc20f444412c54fc8395ca6f2421ad73, and fails when CPython is compiled against expat < 2.6.0: test_subparser_inherits_reparse_deferral (test.test_pyexpat.ParentParserLifetimeTest.test_subparser_inherits_reparse_deferral) ... FAIL ====================================================================== FAIL: test_subparser_inherits_reparse_deferral (test.test_pyexpat.ParentParserLifetimeTest.test_subparser_inherits_reparse_deferral) ---------------------------------------------------------------------- Traceback (most recent call last): File "/builddir/build/BUILD/Python-3.13.15/Lib/test/test_pyexpat.py", line 960, in test_subparser_inherits_reparse_deferral self.assertEqual(subparser.GetReparseDeferralEnabled(), enabled) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: False != True ---------------------------------------------------------------------- With XML_COMBINED_VERSION < 20600, SetReparseDeferralEnabled is a complete no-op[1], both the expat call and the cache update are inside #if XML_COMBINED_VERSION >= 20600. The cache stays at its initial value of false[2], which the subparser copies and GetReparseDeferralEnabled returns. The test's enabled=True iteration then asserts False == True. This is consistent with the documented behavior[3]: GetReparseDeferralEnabled says "always returns false with Expat <2.6.0". Hence, the test makes no sense on Expat < 2.6.0. Similarly to gh-144739, the test's skip decorator needs to check for the compile-time Expat version, as the behavior is determined by #ifs, not by runtime capabilities. Python compiled with Expat 2.5.x still fails the test even if Expat was updated to 2.6.0+ on runtime. We originally saw the test failure in EPEL 9 (has expat 2.5.0 with some security backports), when we updated to Python 3.13.15. I used LLM to analyze the cause of the test failure. [1] https://github.com/python/cpython/blob/v3.15.0rc1/Modules/pyexpat.c#L847-L850 [2] https://github.com/python/cpython/blob/v3.15.0rc1/Modules/pyexpat.c#L1529 [3] https://github.com/python/cpython/blob/v3.15.0rc1/Modules/pyexpat.c#L858 Assisted-By: Claude Opus 4.6 --- Lib/test/test_pyexpat.py | 7 +++++++ .../Tests/2026-08-11-13-03-14.gh-issue-155485.UliOyg.rst | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 Misc/NEWS.d/next/Tests/2026-08-11-13-03-14.gh-issue-155485.UliOyg.rst diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py index 9869f0e88448cf1..9e16c4dba3dfd7d 100644 --- a/Lib/test/test_pyexpat.py +++ b/Lib/test/test_pyexpat.py @@ -1045,6 +1045,13 @@ def test_parent_parser_outlives_its_subparsers__chain(self): del parser del subparser + # gh-155485: GetReparseDeferralEnabled always returns False with Expat <2.6.0. + # Hence, we skip this test when pyxepat was compiled with Expat <2.6.0. + # We check the default value on a new parser instance to detect + # the compile-time expat version, rather than checking expat.version_info + # which stores the runtime expat version (to avoid problems like gh-144739). + @unittest.skipIf(not expat.ParserCreate().GetReparseDeferralEnabled(), + "requires Python compiled with Expat >= 2.6.0") def test_subparser_inherits_reparse_deferral(self): for enabled in (True, False): parser = expat.ParserCreate() diff --git a/Misc/NEWS.d/next/Tests/2026-08-11-13-03-14.gh-issue-155485.UliOyg.rst b/Misc/NEWS.d/next/Tests/2026-08-11-13-03-14.gh-issue-155485.UliOyg.rst new file mode 100644 index 000000000000000..038bb8bb56927b6 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-08-11-13-03-14.gh-issue-155485.UliOyg.rst @@ -0,0 +1,4 @@ +Skip ``test_subparser_inherits_reparse_deferral`` in ``test_pyexpat`` when +Python was compiled against Expat < 2.6.0. +:meth:`~xml.parsers.expat.xmlparser.GetReparseDeferralEnabled` +always returns false with this Expat version and hence the test does not work. From aec4b313d9d69b95aa38fd86c5836ada9bd3183e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 11 Aug 2026 16:59:56 +0200 Subject: [PATCH 2/3] Less verbose comment Co-authored-by: Stan Ulbrych --- Lib/test/test_pyexpat.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py index 9e16c4dba3dfd7d..baa4f178427d532 100644 --- a/Lib/test/test_pyexpat.py +++ b/Lib/test/test_pyexpat.py @@ -1046,10 +1046,6 @@ def test_parent_parser_outlives_its_subparsers__chain(self): del subparser # gh-155485: GetReparseDeferralEnabled always returns False with Expat <2.6.0. - # Hence, we skip this test when pyxepat was compiled with Expat <2.6.0. - # We check the default value on a new parser instance to detect - # the compile-time expat version, rather than checking expat.version_info - # which stores the runtime expat version (to avoid problems like gh-144739). @unittest.skipIf(not expat.ParserCreate().GetReparseDeferralEnabled(), "requires Python compiled with Expat >= 2.6.0") def test_subparser_inherits_reparse_deferral(self): From 6edeea9bd620c584d1cf6bbf56d673960ca6bab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 11 Aug 2026 17:00:45 +0200 Subject: [PATCH 3/3] Remove blurb --- .../next/Tests/2026-08-11-13-03-14.gh-issue-155485.UliOyg.rst | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 Misc/NEWS.d/next/Tests/2026-08-11-13-03-14.gh-issue-155485.UliOyg.rst diff --git a/Misc/NEWS.d/next/Tests/2026-08-11-13-03-14.gh-issue-155485.UliOyg.rst b/Misc/NEWS.d/next/Tests/2026-08-11-13-03-14.gh-issue-155485.UliOyg.rst deleted file mode 100644 index 038bb8bb56927b6..000000000000000 --- a/Misc/NEWS.d/next/Tests/2026-08-11-13-03-14.gh-issue-155485.UliOyg.rst +++ /dev/null @@ -1,4 +0,0 @@ -Skip ``test_subparser_inherits_reparse_deferral`` in ``test_pyexpat`` when -Python was compiled against Expat < 2.6.0. -:meth:`~xml.parsers.expat.xmlparser.GetReparseDeferralEnabled` -always returns false with this Expat version and hence the test does not work.