From: Thomas H. <th...@ct...> - 2013-11-28 20:40:18
|
I experimented a bit. Replaced all the windows api calls by their _W variant, and used wchar_t throughout the code in start.c. Then I constructed a PyObject* containing a list with one unicode object in it, created with PyUnicode_FromWideChar(). Extended the python boot code (in py2exe\boot_common.py) to print sys.path; but the result was this (a byte path): PATH ['c:\\Users\\thomas\\devel\\py2exe\\test\\??\\sme.exe'] So, it seems that Python converts unicode objects on sys.path to byte strings, probably with the mbcs encoding, and this byte string cannot represent these chinese characters on my system. The only idea that I still have is to construct the zipimporter object (which contains the archive with the *strange* filename already) in the py2exe startup code (in C), and inject it into sys.metapath or whatever before any imports in Python takes place. No idea if this will work or not. Am 28.11.2013 16:37, schrieb Thomas Heller: > BTW: Please post the answers to the mailing list! > > Am 28.11.2013 14:47, schrieb goat: >> >>> Interesting idea. For executables; but this cannot be used for dlls... >> >> It is possible to retrieve the literal path of a DLL regardless of the >> exe it is attached to. > > Sure, but it is at least *not nice* to change the current directory > of an exe from a dll when it is loaded. > >> I have to test the functionality around, not 100% >> of the calls to perform. Would also need to detect whether the code is >> called as an exe or a DLL, nothing too hard either. >> >> I'm going to try and implement these fixes and submit a new patch >> somewhere around tonight or tomorrow morning. >> >> Apparently you can set the environment variable PYTHONIOENCODING before >> calling Py_Initialize(), I'll give it a look as well. PYTHONIOENCODING is used only for stdin/stdout/stderr. |