Problems Saving Files
Julián Ciccalè <[email protected]>
| Newsgroups | gmane.comp.python.spe.user |
|---|---|
| Message-ID | <[email protected]> |
Im using spe 0.4.2.a on Windows with Python and almost every time I hit
save
, the file is written but with 0 bytes! Looking more carefully I found that
My python file contains non-ASCII character (I am from Spain). Well
The interesting thing is that first:
The file does not get saved, but worst, get saved with zero bytes, because
the call
To str fails and returns a null string.
And second there is no warning or error reporting (if you dont look at the
console)
Of the exception:
UnicodeEncodeError: 'ascii' codec can't encode character
I found that changing lines 489 and 490 of file
spe/framework/wxMDIChildFrame1.py
From:
file= open(str(self.fileName),'w')
file.write(str(source.replace('\r\n','\n') ) )
To (importing codecs at top):
file=codecs.open(str(self.fileName),'w', 'utf8')
file.write(source.replace(u'\r\n',u'\n'))
Solves, the problem, I did not tried to see how to report and error message
(I downloaded SPE yesterday)
But I will pleased to help. Also I dont know if this is fair for non utf8
users, but there must be a way to get
The users encoding, and not ascii.
SPE is the best python IDE and it rocks.
Julian