Skip to content

gh-155485: Skip test_subparser_inherits_reparse_deferral with Expat < 2.6.0 - #155554

Merged
StanFromIreland merged 3 commits into
python:mainfrom
hroncok:gh155485
Aug 11, 2026
Merged

gh-155485: Skip test_subparser_inherits_reparse_deferral with Expat < 2.6.0#155554
StanFromIreland merged 3 commits into
python:mainfrom
hroncok:gh155485

Conversation

@hroncok

@hroncok hroncok commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

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 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

…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
@hroncok

hroncok commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

I am double-checking this now in our EPEL 9 python3.13 RPM package.

@hroncok

hroncok commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

I am double-checking this now in our EPEL 9 python3.13 RPM package.

Works for us on x86_64 and aarch64 at least.

Comment thread Misc/NEWS.d/next/Tests/2026-08-11-13-03-14.gh-issue-155485.UliOyg.rst Outdated
Comment thread Lib/test/test_pyexpat.py Outdated
hroncok and others added 2 commits August 11, 2026 16:59
Co-authored-by: Stan Ulbrych <stan@python.org>
@StanFromIreland
StanFromIreland merged commit 76d556e into python:main Aug 11, 2026
54 checks passed
@StanFromIreland StanFromIreland added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Aug 11, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @hroncok for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @hroncok for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @hroncok for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Aug 11, 2026

Copy link
Copy Markdown

GH-155572 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 11, 2026
@bedevere-app

bedevere-app Bot commented Aug 11, 2026

Copy link
Copy Markdown

GH-155573 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Aug 11, 2026
@bedevere-app

bedevere-app Bot commented Aug 11, 2026

Copy link
Copy Markdown

GH-155574 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Aug 11, 2026
@StanFromIreland

Copy link
Copy Markdown
Member

Merged, thanks.

@hroncok

hroncok commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review.

@hroncok
hroncok deleted the gh155485 branch August 11, 2026 16:05
StanFromIreland added a commit that referenced this pull request Aug 11, 2026
…deferral` when Expat < 2.6.0 (GH-155554) (#155573)

(cherry picked from commit 76d556e)

Assisted-By: Claude Opus 4.6
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
Co-authored-by: Stan Ulbrych <stan@python.org>
StanFromIreland added a commit that referenced this pull request Aug 11, 2026
…deferral` when Expat < 2.6.0 (GH-155554) (#155572)

(cherry picked from commit 76d556e)


Assisted-By: Claude Opus 4.6

Co-authored-by: Miro Hrončok <miro@hroncok.cz>
Co-authored-by: Stan Ulbrych <stan@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants