]> git.saurik.com Git - wxWidgets.git/commitdiff
Log the exception when writing to file fails.
authorRobin Dunn <robin@alldunn.com>
Tue, 14 Jun 2005 22:59:21 +0000 (22:59 +0000)
committerRobin Dunn <robin@alldunn.com>
Tue, 14 Jun 2005 22:59:21 +0000 (22:59 +0000)
Set the default encoding from wxGetDefaultPyEncoding again.
Recover from encoding errors when writing the memory file.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34657 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/wx/tools/XRCed/globals.py
wxPython/wx/tools/XRCed/tree.py
wxPython/wx/tools/XRCed/xrced.py

index 6ab35862d9ae2df72086b8cd028ff601336f4958..61ea8c0b5568b69d3b4116d65cf83789a2a8487b 100644 (file)
@@ -17,10 +17,9 @@ import sys
 progname = 'XRCed'
 version = '0.1.5-2'
 # Can be changed to set other default encoding different
-defaultEncoding = ''
+#defaultEncoding = ''
 # you comment above and can uncomment this:
-#import wx
-#defaultEncoding = wx.GetDefaultPyEncoding()
+defaultEncoding = wxGetDefaultPyEncoding()
 
 try:
     True
index 249bad55c882e0d2c1cb35723704f4d55125cd84..a917f133adfb81e155c6df9e58ca9914fcb550ec 100644 (file)
@@ -20,9 +20,14 @@ class MemoryFile:
         self.buffer = ''
     def write(self, data):
         if g.currentEncoding:
-            self.buffer += data.encode(g.currentEncoding)
+            encoding = g.currentEncoding
         else:
-            self.buffer += data.encode()
+            encoding = wxGetDefaultPyEncoding()
+        try:
+            self.buffer += data.encode(encoding)
+        except UnicodeEncodeError:
+            self.buffer += data.encode(encoding, 'xmlcharrefreplace')
+            
     def close(self):
         wxMemoryFSHandler_AddFile(self.name, self.buffer)
 
index 1cdb52788e8090a77633859378e866f029986499..730bf823bad7e148bcb7247021b3f3a4df4f3f60 100644 (file)
@@ -716,7 +716,6 @@ Homepage: http://xrced.sourceforge.net\
 
     # Simple emulation of python command line
     def OnDebugCMD(self, evt):
-        import traceback
         while 1:
             try:
                 exec raw_input('C:\> ')
@@ -1033,6 +1032,8 @@ Homepage: http://xrced.sourceforge.net\
             self.modified = False
             panel.SetModified(False)
         except:
+            inf = sys.exc_info()
+            wxLogError(traceback.format_exception(inf[0], inf[1], None)[-1])
             wxLogError('Error writing file: %s' % path)
             raise