summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-02-09 16:53:09 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-02-09 16:53:09 (GMT)
commit54319287c9b3df17c0f6ce15b14619a9814ae292 (patch)
tree24718ad101ee49d9c2fddfe86d0bb61668b005c0 /Lib/test
parent0f36573f10fb1125042ada81b9feaee0c5b8a9ff (diff)
downloadcpython-54319287c9b3df17c0f6ce15b14619a9814ae292.zip
cpython-54319287c9b3df17c0f6ce15b14619a9814ae292.tar.gz
cpython-54319287c9b3df17c0f6ce15b14619a9814ae292.tar.bz2
Merged revisions 78123 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r78123 | antoine.pitrou | 2010-02-09 17:51:16 +0100 (mar., 09 févr. 2010) | 5 lines Issue #6233: ElementTree failed converting unicode characters to XML entities when they could't be represented in the requested output encoding. Patch by Jerry Chen. ........
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_xml_etree.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 895902f..a7ad48b 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -210,6 +210,17 @@ def check_encoding(ET, encoding):
"""
ET.XML("<?xml version='1.0' encoding='%s'?><xml />" % encoding)
+def check_issue6233():
+ """
+ >>> from xml.etree import ElementTree as ET
+
+ >>> e = ET.XML("<?xml version='1.0' encoding='utf-8'?><body>t\xe3g</body>")
+ >>> ET.tostring(e, 'ascii')
+ b"<?xml version='1.0' encoding='ascii'?>\\n<body>t&#227;g</body>"
+ >>> e = ET.XML("<?xml version='1.0' encoding='iso-8859-1'?><body>t\xe3g</body>".encode('iso-8859-1')) # create byte string with the right encoding
+ >>> ET.tostring(e, 'ascii')
+ b"<?xml version='1.0' encoding='ascii'?>\\n<body>t&#227;g</body>"
+ """
#
# xinclude tests (samples from appendix C of the xinclude specification)