Log the exception when writing to file fails.

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
This commit is contained in:
Robin Dunn
2005-06-14 22:59:21 +00:00
parent aae5d34f85
commit 4eb5bfc61f
3 changed files with 11 additions and 6 deletions

View 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)