Thread: [Boa Constr] boa & unicode : sitecustomize.py not read
Status: Beta
Brought to you by:
riaan
From: spir <den...@fr...> - 2008-09-29 09:02:51
|
Hello, I read in the doc that, in order to use unicode with boa, one should add a sitecustomize.py module with a setdefaultencoding("utf-8") instruction, either to the python directory, or to the Lib/site-packages one, or to the boa directory. I choose the last solution in order not to disturb other modules. Note that my source files always start with "# -*- coding:utf-8 -*-". But it does not work. Actually, sitecustomize.py is not even read, there is no .pyc file generated. When I try to open a source file with non-ascii chars, I get the usual ascii codec error, for instance: "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 27: ordinal not in range(128)" (Oxe9 is the code for 'é'). Copying sitecustomize.py to the python directory does not solve the problem. In fact, this kind of error messages even constantly happens in the boa file-open dialog, even though my directory and file names don't hold any non-ascii character. Thank you for help, Denis |
From: Werner F. B. <wer...@fr...> - 2008-09-29 22:05:42
|
Denis, spir wrote: > Hello, > > I read in the doc that, in order to use unicode with boa, one should add > a sitecustomize.py module with a setdefaultencoding("utf-8") > instruction, either to the python directory, or to the Lib/site-packages > one, or to the boa directory. I choose the last solution in order not to > disturb other modules. > Note that my source files always start with "# -*- coding:utf-8 -*-". > But it does not work. Actually, sitecustomize.py is not even read, there > is no .pyc file generated. When I try to open a source file with > non-ascii chars, I get the usual ascii codec error, for instance: > "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position > 27: ordinal not in range(128)" (Oxe9 is the code for 'é'). > Copying sitecustomize.py to the python directory does not solve the > problem. In fact, this kind of error messages even constantly happens in > the boa file-open dialog, even though my directory and file names don't > hold any non-ascii character. # Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] # wxPython 2.8.8.1, Boa Constructor 0.6.1 # Type "copyright", "credits" or "license" for more information. >>> import sys >>> sys.getdefaultencoding() 'utf-8' >>> I work in Unicode for some time now with Boa. My sitecustomize.py is in the Python root. Can you provide more information on what you are running, i.e. Boa version, and OS. Also, I hope that you are not using the boa.exe as that would explain why non of the locations for your sitecustomize.py seem to work. The .exe version is built with py2exe and therefor will use whatever is it was built against (which is an ANSI build). Werner |
From: Werner F. B. <wer...@fr...> - 2008-09-30 13:26:15
|
Denis, spir wrote: > Thank you for your help, Werner. > I work on windows with last versions installed I guess : > * win XP SP3 > * python 2.5.2 > * wxPython 2.8.81 > * boa 0.6.1 > > Actually, you're right, I use the exe version of boa, which explains > why sitecustomize.py does not work. I should have noted that myself... > Still, the strange thing is : I just installed ACtiveState's > ActivePython instead of the standard Cpython. And *now*, boa works > perfectly with unicode, both when opening and running a file. wxPython > modules such as the file dialog, too (before I had warnings at each > directory change, even if there are only plain ascii file and > directory names). No idea, I thought that ActivePython is just a "packaged" up Cpython with some other modules, but as they are always lagging a bit behind I prefer to get the packages/modules I need and to upgrade them when it fits into my plans. > > I would really enjoy understanding. Does it mean that ActivePython is > internally built using unicode ? And written in order to be able to > parse unicode source files ? If it uses utf-8, then ascii users would > not even notice it (characters < 128 still coded on a single byte). > Anyway, this fact shows that I still don't get fully the way python > copes with non-ascii stuff. I don't mean non-ascii data, or the > unicode type of strings, but the encoding of the source code itself. You might want to search with Google there are lots of references/posts/wiki pages out there. It is still a mystery to me, also I think I have my application converted over to Unicode, actually utf-8, but still testing. > > greetings, denis > > PS : Do you know about a programming language in which variable and > object _names_ can be non-ascii ? I think in the XXIth century this > should be possible ;-) You probably could today with Python, also it might be a lot easier with Python 3x as I believe it will be handling Unicode "natively", i.e. it will be the default and no longer ascii. I am a native German speaker but all the code in my app uses English for all objects etc etc, and I then use gettext to translate all the user visible stuff into German and French. Werner |
From: Riaan B. <riaan@e.co.za> - 2008-09-29 12:39:57
|
Hi Denis, You are probably using the exe version of Boa, that means that everything is compiled into the exe and no external py files like sitecustomize.py are run. You can still set the default encoding via the command-line switch -U, e.g. Boa.exe -U utf-8 But as the exe version uses the ascii version of wxPython it may still give issues. I suggest you use the source version of Boa. Cheers, Riaan. 2008/9/29 spir <den...@fr...>: > Hello, > > I read in the doc that, in order to use unicode with boa, one should add > a sitecustomize.py module with a setdefaultencoding("utf-8") > instruction, either to the python directory, or to the Lib/site-packages > one, or to the boa directory. I choose the last solution in order not to > disturb other modules. > Note that my source files always start with "# -*- coding:utf-8 -*-". > But it does not work. Actually, sitecustomize.py is not even read, there > is no .pyc file generated. When I try to open a source file with > non-ascii chars, I get the usual ascii codec error, for instance: > "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position > 27: ordinal not in range(128)" (Oxe9 is the code for 'é'). > Copying sitecustomize.py to the python directory does not solve the > problem. In fact, this kind of error messages even constantly happens in > the boa file-open dialog, even though my directory and file names don't > hold any non-ascii character. > > Thank you for help, > Denis > > > > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Boa-constructor-users mailing list > Boa...@li... > https://lists.sourceforge.net/lists/listinfo/boa-constructor-users > |