This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients Peter.Cai, belopolsky
Date 2011-02-02.16:08:43
SpamBayes Score 2.8350755e-09
Marked as misclassified No
Message-id <1296662924.26.0.92491328286.issue11033@psf.upfronthosting.co.za>
In-reply-to
Content
This works in 3.x:

Python 3.2rc2+ (py3k:88279:88280, Feb  1 2011, 00:01:52)
..
>>> from xml.etree import ElementTree
>>> ElementTree.fromstring('<doc>诗</doc>')
<Element 'doc' at 0x1007daa00>

In 2.x you need to encode unicode strings before passing them to ElementTree.fromstring().  For example:

----
# encoding: utf-8                                                                                                                                                      
from xml.etree import ElementTree
t = ElementTree.fromstring(u'<doc>诗</doc>'.encode('utf-8'))
print t.text
----

This is not a bug because fromstring() unlike some other ElementTree methods is not documented to support unicode strings. Since 2.x is closed for new features, this has to be rejected.
History
Date User Action Args
2011-02-02 16:08:44belopolskysetrecipients: + belopolsky, Peter.Cai
2011-02-02 16:08:44belopolskysetmessageid: <1296662924.26.0.92491328286.issue11033@psf.upfronthosting.co.za>
2011-02-02 16:08:43belopolskylinkissue11033 messages
2011-02-02 16:08:43belopolskycreate