")
->>> ET.ElementTree(element).write(sys.stdout)
+>>> ET.ElementTree(element).write(sys.stdout, encoding='unicode')
text
>>> element = ET.fromstring("text")
->>> ET.ElementTree(element).write(sys.stdout)
+>>> ET.ElementTree(element).write(sys.stdout, encoding='unicode')
text
>>> sequence = ["", "text"]
>>> element = ET.fromstringlist(sequence)
>>> print(ET.tostring(element))
- text
->>> print("".join(ET.tostringlist(element)))
- text
+ b'text'
+>>> print(b"".join(ET.tostringlist(element)))
+ b'text'
>>> ET.tostring(element, "ascii")
b"\\ntext"
>>> _, ids = ET.XMLID("text")
@@ -870,10 +870,10 @@
"""
>>> elem = ET.XML("text")
>>> ET.tostring(elem)
- 'text'
+ b'text'
>>> elem = ET.fromstring("text")
>>> ET.tostring(elem)
- 'text'
+ b'text'
"""
def check_encoding(encoding):
@@ -1228,14 +1228,14 @@
Test ProcessingInstruction directly
>>> ET.tostring(ET.ProcessingInstruction('test', 'instruction'))
- ''
+ b''
>>> ET.tostring(ET.PI('test', 'instruction'))
- ''
+ b''
Issue #2746
>>> ET.tostring(ET.PI('test', '