Kaydet (Commit) 55b15c9f authored tarafından Guido van Rossum's avatar Guido van Rossum

Fix the test_minidom failure.

We just need to force the encoding when no encoding is passed to toxml()
or toprettyxml(), rather than relying on the default encoding (which is
unreliable).
üst bdba5cf6
...@@ -48,7 +48,8 @@ class Node(xml.dom.Node): ...@@ -48,7 +48,8 @@ class Node(xml.dom.Node):
def toprettyxml(self, indent="\t", newl="\n", encoding=None): def toprettyxml(self, indent="\t", newl="\n", encoding=None):
# indent = the indentation string to prepend, per level # indent = the indentation string to prepend, per level
# newl = the newline string to append # newl = the newline string to append
writer = io.StringIO(encoding=encoding) use_encoding = "utf-8" if encoding is None else encoding
writer = io.StringIO(encoding=use_encoding)
if self.nodeType == Node.DOCUMENT_NODE: if self.nodeType == Node.DOCUMENT_NODE:
# Can pass encoding only to document, to put it into XML header # Can pass encoding only to document, to put it into XML header
self.writexml(writer, "", indent, newl, encoding) self.writexml(writer, "", indent, newl, encoding)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment