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
Bug description
xmlparser.ExternalEntityParserCreate()copies the parent parser's fields onto the new subparser, but missesreparse_deferral_enabled. SincePyObject_GC_Newdoes not zero the struct, that field is read uninitialized, soGetReparseDeferralEnabled()on the subparser returns a garbage value.Expat's own C-level state is inherited correctly (
parserCreatesaves 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