https://github.com/python/cpython/commit/7d760134cc20f444412c54fc8395ca6f2421ad73
commit: 7d760134cc20f444412c54fc8395ca6f2421ad73
branch: main
author: tonghuaroot (童话) <[email protected]>
committer: encukou <[email protected]>
date: 2026-07-31T12:58:59+02:00
summary:
gh-154738: Propagate reparse-deferral setting to pyexpat subparsers (GH-154739)
files:
A Misc/NEWS.d/next/Library/2026-07-26-00-00-00.gh-issue-154738.Rd5Pxe.rst
M Lib/test/test_pyexpat.py
M Modules/pyexpat.c
diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py
index a2ef67baadd4af..54dfa95ce8bff1 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
+ def test_subparser_inherits_reparse_deferral(self):
+ for enabled in (True, False):
+ parser = expat.ParserCreate()
+ parser.SetReparseDeferralEnabled(enabled)
+ subparser = parser.ExternalEntityParserCreate(None)
+ self.assertEqual(subparser.GetReparseDeferralEnabled(), enabled)
+
class ExternalEntityParserCreateErrorTest(unittest.TestCase):
"""ExternalEntityParserCreate error paths should not crash or leak
diff --git
a/Misc/NEWS.d/next/Library/2026-07-26-00-00-00.gh-issue-154738.Rd5Pxe.rst
b/Misc/NEWS.d/next/Library/2026-07-26-00-00-00.gh-issue-154738.Rd5Pxe.rst
new file mode 100644
index 00000000000000..1a6e1a301db466
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-07-26-00-00-00.gh-issue-154738.Rd5Pxe.rst
@@ -0,0 +1,3 @@
+Fix :meth:`!ExternalEntityParserCreate` not propagating the reparse-deferral
+setting to the subparser, which left :meth:`!GetReparseDeferralEnabled`
+returning an uninitialized value. Patch by tonghuaroot.
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index f9e7e057f7e0f7..397a441f574fe4 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1118,6 +1118,7 @@
pyexpat_xmlparser_ExternalEntityParserCreate_impl(xmlparseobject *self,
new_parser->specified_attributes = self->specified_attributes;
new_parser->in_callback = 0;
new_parser->ns_prefixes = self->ns_prefixes;
+ new_parser->reparse_deferral_enabled = self->reparse_deferral_enabled;
new_parser->itself = XML_ExternalEntityParserCreate(self->itself, context,
encoding);
// The new subparser will make use of the parent XML_Parser inside of
Expat.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]