[GRASS-SVN] r54104 - grass/trunk/gui/wxpython/gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Nov 30 01:32:37 PST 2012


Author: martinl
Date: 2012-11-30 01:32:36 -0800 (Fri, 30 Nov 2012)
New Revision: 54104

Modified:
   grass/trunk/gui/wxpython/gui_core/forms.py
Log:
wxGUI/forms: use codecs.open() when writing text files


Modified: grass/trunk/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/forms.py	2012-11-30 09:22:47 UTC (rev 54103)
+++ grass/trunk/gui/wxpython/gui_core/forms.py	2012-11-30 09:32:36 UTC (rev 54104)
@@ -52,10 +52,12 @@
 import os
 import copy
 import locale
-from threading import Thread
 import Queue
 import re
+import codecs
 
+from threading import Thread
+
 gisbase = os.getenv("GISBASE")
 if gisbase is None:
     print >>sys.stderr, "We don't seem to be properly installed, or we are being run outside GRASS. Expect glitches."
@@ -1723,7 +1725,8 @@
 
         if dlg.ShowModal() == wx.ID_OK:
             path = dlg.GetPath()
-            f = open(path, "w")
+            enc = locale.getdefaultlocale()[1]
+            f = codecs.open(path, encoding = enc, mode = 'w', errors='replace')
             try:
                 f.write(text + os.linesep)
             finally:
@@ -1743,11 +1746,11 @@
         if text:
             filename = win.GetValue()
             if not filename:
-                # outFile = tempfile.NamedTemporaryFile(mode = 'w+b')
                 filename = grass.tempfile()
                 win.SetValue(filename)
                 
-            f = open(filename, "w")
+            enc = locale.getdefaultlocale()[1]
+            f = codecs.open(filename, encoding = enc, mode = 'w', errors='replace')
             try:
                 f.write(text)
                 if text[-1] != os.linesep:



More information about the grass-commit mailing list