Eli Bendersky <eli...@gmail.com> added the comment:

Both the Python ET and _elementtree use expat, but reach its parsing function 
in a different path when given a file-like object (StringIO, BytesIO).

Python ET reads the stream itself and passes the data to pyexpat's Parse 
method, which uses PyArg_ParseTuple to decode it. The latter turns a string 
into bytes when required, so the parsing of str streams is handled 
transparently.

For _elementtree, on the other hand, ET directly calls the internal 
XMLParser._parse, which uses its own (C) loop to read from the stream. When it 
sees that it hasn't read bytes (but a string) it stops and falls back on 
parsing an empty document.

The fix will have to be in the latter loop, probably just converting the read 
string to bytes before moving on.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14246>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to