mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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.
This commit is contained in:
parent
28a817e3ba
commit
c77dd32be4
4 changed files with 25 additions and 6 deletions
|
@ -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ã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ãg</body>"
|
||||
"""
|
||||
|
||||
#
|
||||
# xinclude tests (samples from appendix C of the xinclude specification)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue