Message 89623 - Python tracker (original) (raw)

The attached patch includes Neil's original additions to test_xml_etree.py.

I also noticed that _encode_entity wasn't being called in ElementTree in py3k, with the important bit being the nested function escape_entities(), in conjunction with _escape and _escape_map.

In 2.x, _encode_entity() is used after _encode() throws Unicode exceptions [1], so I figured it would make sense to take the core functionality of _escape_entities() and integrate it into _encode in the same fashion -- when an exception is thrown.

Basically, I:

I'm not sure what the expected outcome is supposed to be when the text is not type bytes but str. With this patch, the output has b"tãt" rather than b"tãt".

Hope this is a step in the right direction.

[1] ElementTree.py:814, ElementTree.py:829, python 2.7 HEAD r50941