[Python-3000-checkins] r56812 - python/branches/py3k-struni/Lib/xml/dom/minidom.py

guido.van.rossum python-3000-checkins at python.org
Wed Aug 8 01:03:34 CEST 2007


Author: guido.van.rossum
Date: Wed Aug  8 01:03:33 2007
New Revision: 56812

Modified:
   python/branches/py3k-struni/Lib/xml/dom/minidom.py
Log:
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).


Modified: python/branches/py3k-struni/Lib/xml/dom/minidom.py
==============================================================================
--- python/branches/py3k-struni/Lib/xml/dom/minidom.py	(original)
+++ python/branches/py3k-struni/Lib/xml/dom/minidom.py	Wed Aug  8 01:03:33 2007
@@ -48,7 +48,8 @@
     def toprettyxml(self, indent="\t", newl="\n", encoding=None):
         # indent = the indentation string to prepend, per level
         # 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:
             # Can pass encoding only to document, to put it into XML header
             self.writexml(writer, "", indent, newl, encoding)


More information about the Python-3000-checkins mailing list