mailr17681 - /trunk/data/__init__.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on October 02, 2012 - 17:47:
Author: bugman
Date: Tue Oct  2 17:47:23 2012
New Revision: 17681

URL: http://svn.gna.org/viewcvs/relax?rev=17681&view=rev
Log:
Python 3 fix for the writing out of XML formatted state and results files.

In Python 3, the xmldoc.toprettyxml() returns a string object which needs to 
be 'encoded' prior to
writing out to file.


Modified:
    trunk/data/__init__.py

Modified: trunk/data/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/data/__init__.py?rev=17681&r1=17680&r2=17681&view=diff
==============================================================================
--- trunk/data/__init__.py (original)
+++ trunk/data/__init__.py Tue Oct  2 17:47:23 2012
@@ -573,4 +573,7 @@
             self[pipe].to_xml(xmldoc, pipe_element)
 
         # Write out the XML file.
-        file.write(xmldoc.toprettyxml(indent='    '))
+        text = xmldoc.toprettyxml(indent='    ')
+        if hasattr(text, 'encode'):    # Python 3 string support.
+            text = text.encode()
+        file.write(text)




Related Messages


Powered by MHonArc, Updated Tue Oct 02 18:00:01 2012