https://github.com/python/cpython/commit/f85d8e4cac1ba1efa7e98b6274231703f4be6a7f commit: f85d8e4cac1ba1efa7e98b6274231703f4be6a7f branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: encukou <[email protected]> date: 2026-08-03T17:07:06+02:00 summary:
[3.13] gh-154738: Propagate reparse-deferral setting to pyexpat subparsers (GH-154739) (GH-154989) (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 846a390c9a268f..ae7cec6540160d 100644 --- a/Lib/test/test_pyexpat.py +++ b/Lib/test/test_pyexpat.py @@ -952,6 +952,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 871b05d0953d32..9e5d84eb5e2514 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -1053,6 +1053,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]
