Message127740
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. |
|
Date |
User |
Action |
Args |
2011-02-02 16:08:44 | belopolsky | set | recipients:
+ belopolsky, Peter.Cai |
2011-02-02 16:08:44 | belopolsky | set | messageid: <1296662924.26.0.92491328286.issue11033@psf.upfronthosting.co.za> |
2011-02-02 16:08:43 | belopolsky | link | issue11033 messages |
2011-02-02 16:08:43 | belopolsky | create | |
|