https://github.com/python/cpython/commit/0e10534278be0c099c00f5d4dda6185b99a76594
commit: 0e10534278be0c099c00f5d4dda6185b99a76594
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: encukou <[email protected]>
date: 2026-08-03T17:06:58+02:00
summary:

[3.14] gh-154738: Propagate reparse-deferral setting to pyexpat subparsers 
(GH-154739) (GH-154991)

(cherry picked from commit 7d760134cc20f444412c54fc8395ca6f2421ad73)

Co-authored-by: tonghuaroot (童话) <[email protected]>

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 10e2e5f79908b0..419edfecb9b63d 100644
--- a/Lib/test/test_pyexpat.py
+++ b/Lib/test/test_pyexpat.py
@@ -956,6 +956,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 688f01839a20cc..f9fd7a7a5b2f01 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1084,6 +1084,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]

Reply via email to