gh-155485: Skip test_subparser_inherits_reparse_deferral with Expat < 2.6.0 - #155554
Conversation
…xpat < 2.6.0 The test was added in 7d76013, 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 pythongh-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
|
I am double-checking this now in our EPEL 9 python3.13 RPM package. |
Works for us on x86_64 and aarch64 at least. |
Co-authored-by: Stan Ulbrych <stan@python.org>
|
Thanks @hroncok for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
|
Thanks @hroncok for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Thanks @hroncok for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15. |
|
GH-155572 is a backport of this pull request to the 3.14 branch. |
|
GH-155573 is a backport of this pull request to the 3.13 branch. |
|
GH-155574 is a backport of this pull request to the 3.15 branch. |
|
Merged, thanks. |
|
Thanks for the review. |
The test was added in 7d76013, and fails when CPython is compiled against expat < 2.6.0:
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