Bug description
xmlparser.ExternalEntityParserCreate() copies the parent parser's fields onto the new subparser, but misses reparse_deferral_enabled. Since PyObject_GC_New does not zero the struct, that field is read uninitialized, so GetReparseDeferralEnabled() on the subparser returns a garbage value.
from xml.parsers import expat p = expat.ParserCreate() p.SetReparseDeferralEnabled(False) sub = p.ExternalEntityParserCreate(None) print(sub.GetReparseDeferralEnabled()) # True, should be False
Expat's own C-level state is inherited correctly (parserCreate saves and restores it), so the actual parsing behaviour is fine; only the Python-visible cached value is wrong.
CPython versions tested on
3.13, 3.14, main
Operating systems tested on
macOS
Linked PRs
- gh-154738: Propagate reparse-deferral setting to pyexpat subparsers #154739
- [3.13] gh-154738: Propagate reparse-deferral setting to pyexpat subparsers (GH-154739) #154989
- [3.15] gh-154738: Propagate reparse-deferral setting to pyexpat subparsers (GH-154739) #154990
- [3.14] gh-154738: Propagate reparse-deferral setting to pyexpat subparsers (GH-154739) #154991