[spe.pycs.net] mailing list active ? problem with 0.5.1.E

mail at benno-dielmann.de mail at benno-dielmann.de
Wed Sep 8 13:55:47 CEST 2004


Hi, 

>Here's my configuration:
>
>*Program info*
>
>Spe version 	0.5.1.e
>Python version 	2.3.2  (2.2 required)
>wxPython version 	2.5.2.7.u  (2.4.2.4. required)
>  	 
>Spe location 	C:\pl\Python23\lib\site-packages\_spe 
><C:%5Cpl%5CPython23%5Clib%5Csite-packages%5C_spe>
>Blenpy location 	C:\pl\Python23\lib\site-packages\blenpy 
><C:%5Cpl%5CPython23%5Clib%5Csite-packages%5Cblenpy>
>Sm location 	C:\pl\Python23\lib\site-packages\sm 
><C:%5Cpl%5CPython23%5Clib%5Csite-packages%5Csm>
>Sm idle location 	C:\pl\Python23\lib\site-packages\sm 
><C:%5Cpl%5CPython23%5Clib%5Csite-packages%5Csm>
>User path 	C:\Documents and Settings\Dagur Pall Ammendrup\.spe 
><C:%5CDocuments%20and%20Settings%5CDagur%20Pall%20Ammendrup%5C.spe>
>
>
>I couldn't find any error log but I always got a unicode error like this:
>
>UnicodeEncodeError: 'ascii' codec can't encode character u'\xe6' in 
>position 62: ordinal not in range(128)
>
>After some testing I think it has to do with special characters in the 
>directory name. It wouldn't save at all in a directory called 
>stærðfræðigreining but I could save in other directories. What's strange 
>though is that I sometimes got errors when saving in the other 
>directories, but in those cases the file would be saved anyway.
>
>I'm on Windows XP pro SP2.
>

In fact it probably hasn't anything to do with the characters in the directory name but with that ones in your file. 

The reason is a "feature" in the wxStyledTextControl from wxPython Spe uses. This text control always tries to save files with the python standard encoding which happens to be ascii out of the box. If your file isn't ascii encoded (e.g. if you are using non-ascii chars in comments or strings), you get the above error. 

Perhaps the problem arises as well with non-ascii directory names, but I haven't tested that. 

The solution I found will probably work any way so here is it:

In the "site-packages" directory in my python dir (/usr/lib/python/site-packages on my linux box) I created a file named "sitecustomize.py" with the following content:

-----------------
import sys

sys.setdefaultencoding('iso-8859-1')
-----------------

This script is run automatically on python startup and sets the default encoding to 'iso-8859-1'. Please insert your appropriate encoding, e.g. 'utf-8'. 

Everything should work fine now. 

Bye, 

Benno.




More information about the Spe-user mailing list