New submission from Allan Crooks: There seems to be a specific issue when using cElementTree.parse on a StringIO object containing unicode text - it generates a ParseError.
I've tried variations of ElementTree and cElementTree, variations of StringIO and cStringIO, and used str and unicode types. It seems there is one combination of these that generates the problem. I tried this on Python 2.7.5 - this bit of code shows the inconsistency we've got: >>> from xml.etree import ElementTree as ET, cElementTree as CET >>> from StringIO import StringIO as SIO >>> from cStringIO import StringIO as CSIO >>> xml, uxml = '<simple />', u'<simple />' >>> >>> def parse(etree_impl, strio_class, text): ... try: ... return etree_impl.parse(strio_class(text)) ... except Exception as e: ... return 'ERROR: ' + repr(e) ... >>> for etree_var in 'ET CET'.split(): ... for sio_var in 'SIO CSIO'.split(): ... for xml_var in 'xml uxml'.split(): ... print etree_var, sio_var, xml_var, ... print parse(vars()[etree_var], vars()[sio_var], vars()[xml_var]) ... ET SIO xml <xml.etree.ElementTree.ElementTree object at 0x7f92c795ec90> ET SIO uxml <xml.etree.ElementTree.ElementTree object at 0x7f92c795ec90> ET CSIO xml <xml.etree.ElementTree.ElementTree object at 0x7f92c795ec90> ET CSIO uxml <xml.etree.ElementTree.ElementTree object at 0x7f92c795ec90> CET SIO xml <ElementTree object at 0x7f92c795ec90> CET SIO uxml ERROR: ParseError('no element found: line 1, column 0',) CET CSIO xml <ElementTree object at 0x7f92c795ec90> CET CSIO uxml <ElementTree object at 0x7f92c795ec90> ---------- components: XML messages: 211114 nosy: amcone priority: normal severity: normal status: open title: cElementTree has problems with StringIO object containing unicode content type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20612> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com