Christian Heimes added the comment: Alexandre Vassalotti wrote: > That isn't true. My mangler does exactly the same thing as your > original one. > > However, I forgot to add Py_CHARMASK to the calls of tolower() and > isalnum() which would cause problems on platforms with signed char.
I wasn't sure how tolower() reacts on numeric values. The addition of Py_CHARMASK is a good idea. It's a shame stringobject.c doesn't expose its non locale version of tolower() and isalnum(). > Maybe adding a global variable, let's say _Py_Codecs_Ready, could be > used to notify PyUnicode_DecodeFSDefault that it can use > PyUnicode_Decode, instead of relying only on the built-in codecs. That > would be much simpler than changing boostrapping process. It still f... up the file names of Python modules that were loaded before the codecs are ready to use. What do you think about this (pseudocode): #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) return PyUnicode_DecodeMBCS(string, "replace) #elif defined(__APPLE__) return PyUnicode_DecodeUTF8(string, "replace) #else * set __file__ and co_filename to a preliminary value with PyUnicode_DecodeUTF8(string, "replace") * Store a pointer and original string in a linked list struct Py_FixFileNames { struct Py_FixFileNames *next; char *string; PyObject *unicode; }; * After the codecs and Py_FileSystemDefaultEncoding are set up in Py_InitializeEx() check the value. If the fs default encoding isn't UTF-8 redo all encodings with the correct encoding. * Free the linked list * From now on use the codecs package, PyUnicode_Decode() and Py_FileSystemDefaultEncoding for every filename #endif Add comments to See Python/bltinmodule.c Py_FileSystemDefaultEncoding and Objects/unicodeobject.c unicode_default_encoding that PyUnicode_DecodeFSDefault depends on the values. It ain't beautiful and fast but we definitely get the right file names after boot strapping and fair file names during boot strapping. Christian __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1272> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com