"""
ET.XML("<?xml version='1.0' encoding='%s'?><xml />" % encoding)
+def processinginstruction():
+ """
+ Test ProcessingInstruction directly
+
+ >>> from xml.etree import ElementTree as ET
+
+ >>> ET.tostring(ET.ProcessingInstruction('test', 'instruction'))
+ '<?test instruction?>'
+ >>> ET.tostring(ET.PI('test', 'instruction'))
+ '<?test instruction?>'
+
+ Issue #2746
+
+ >>> ET.tostring(ET.PI('test', '<testing&>'))
+ '<?test <testing&>?>'
+
+ """
#
# xinclude tests (samples from appendix C of the xinclude specification)
# write XML to file
tag = node.tag
if tag is Comment:
- file.write("<!-- %s -->" % _escape_cdata(node.text, encoding))
+ file.write("<!-- %s -->" % _encode(node.text, encoding))
elif tag is ProcessingInstruction:
- file.write("<?%s?>" % _escape_cdata(node.text, encoding))
+ file.write("<?%s?>" % _encode(node.text, encoding))
else:
items = node.items()
xmlns_items = [] # new namespaces in this scope
Sjoerd Mullender
Sape Mullender
Michael Muller
+Neil Muller
R. David Murray
Piotr Meyer
John Nagle
Library
-------
+- Issue #2746: Don't escape ampersands and angle brackets ("&", "<", ">")
+ in XML processing instructions and comments. These raw characters are
+ allowed by the XML specification, and are necessary when outputting e.g.
+ PHP code in a processing instruction. Patch by Neil Muller.
+
- Issue #7869: logging: improved diagnostic for format-time errors.
- Issue #7868: logging: added loggerClass attribute to Manager.