[spe.pycs.net] Problems Saving Files

Julián Ciccalè julian at seamus.es
Sat Jan 3 10:57:23 CET 2004


I’m 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 don’t 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 don’t 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/spe-user/attachments/20040103/772bab55/attachment.htm 


More information about the Spe-user mailing list