[New-bugs-announce] [issue19483] Pure-Python ElementTree classes no longer available since 3.3

Brecht Machiels report at bugs.python.org
Sun Nov 3 11:58:40 CET 2013


New submission from Brecht Machiels:

With Python 3.2, I subclassed ElementTree.XMLParser to set ExternalEntityRefHandler on the XMLParser's (expat) 'parser' member. I understand the 'parser' member is not part of the public API, but this was the only way to customize the parser without having to write a parser from scratch.

With 3.3, cElementTree replaces the Python implementation by default. Its XMLParser class has no accessible 'parser' member to configure. Unfortunately, there does not seem to be a way to use the pure-Python XMLParser, which would still allow for customization of the parser. Why is the Python version still in the library if it can't be accessed? Only for platforms where the C extension is not available?

I see two possible solutions:

1) Have XMLParser (both the C and Python versions) accept an optional parser argument, so that a custom parser can be passed in.

2) Make the Python version of ElementTree available again.

My other option is to copy the Python XMLParser version into my project. I would like to avoid this, as this would duplicate a lot of perfectly good code.
Perhaps there are other solutions?

----------
components: XML
messages: 202011
nosy: brechtm, eli.bendersky, scoder
priority: normal
severity: normal
status: open
title: Pure-Python ElementTree classes no longer available since 3.3
type: behavior
versions: Python 3.3, Python 3.4, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19483>
_______________________________________


More information about the New-bugs-announce mailing list