Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55b15c9

Browse files
committed
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).
1 parent bdba5cf commit 55b15c9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Lib/xml/dom/minidom.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def toxml(self, encoding = None):
4848
def toprettyxml(self, indent="\t", newl="\n", encoding=None):
4949
# indent = the indentation string to prepend, per level
5050
# newl = the newline string to append
51-
writer = io.StringIO(encoding=encoding)
51+
use_encoding = "utf-8" if encoding is None else encoding
52+
writer = io.StringIO(encoding=use_encoding)
5253
if self.nodeType == Node.DOCUMENT_NODE:
5354
# Can pass encoding only to document, to put it into XML header
5455
self.writexml(writer, "", indent, newl, encoding)

0 commit comments

Comments
 (0)