Issues with XMLTreeBuilder in cElementTree and ElementTree
Stefan Behnel
stefan_ml at behnel.de
Sun Mar 23 12:51:21 EDT 2008
Michael Becker wrote:
> Secondly, I found a potential issue with the cElementTree module. My
> understanding (which could be incorrect) of python C modules is that
> they should work the same as the python versions but be more
> efficient. The XMLTreeBuilder class in cElementTree doesn't seem to be
> using the same parser as that in ElementTree. The following code
> illustrates this issue:
>
>>>> import xml.etree.cElementTree
>>>> t1=xml.etree.cElementTree.XMLTreeBuilder()
>>>> t1._parser.ordered_attributes = 1
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> AttributeError: _parser
>>>> import xml.etree.ElementTree
>>>> t1=xml.etree.ElementTree.XMLTreeBuilder()
>>>> t1._parser.ordered_attributes = 1
Mind the underscore. You are using a non-public interface here. Don't expect
other implementations to support that.
Stefan
More information about the Python-list
mailing list