This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients amaury.forgeotdarc, benjamin.peterson, christian.heimes, eric.araujo, grahamd, loewis, ncoghlan, pitrou, python-dev, tarek, vstinner
Date 2011-04-25.21:51:08
SpamBayes Score 6.306203e-05
Marked as misclassified No
Message-id <1303768269.04.0.928915307898.issue10914@psf.upfronthosting.co.za>
In-reply-to
Content
> I think that Python used interp->codecs_initialized flag

Yes in PyUnicode_AsEncodedString(), in Python 3.0 and 3.1. Python 3.2 has also the test, but PyUnicode_AsEncodedString() is no more used to encode filenames. I removed the test in Python 3.3.

Extract of Python 3.1:

        /* During bootstrap, we may need to find the encodings
           package, to load the file system encoding, and require the
           file system encoding in order to load the encodings
           package.

           Break out of this dependency by assuming that the path to
           the encodings module is ASCII-only.  XXX could try wcstombs
           instead, if the file system encoding is the locale's
           encoding. */
        else if (Py_FileSystemDefaultEncoding &&
                 strcmp(encoding, Py_FileSystemDefaultEncoding) == 0 &&
                 !PyThreadState_GET()->interp->codecs_initialized)
            return PyUnicode_AsASCIIString(unicode);

I implemented the "XXX could try wcstombs" part, but in new functions:  PyUnicode_EncodeFSDefault and PyUnicode_DecodeFSDefaultAndSize.
History
Date User Action Args
2011-04-25 21:51:09vstinnersetrecipients: + vstinner, loewis, amaury.forgeotdarc, ncoghlan, pitrou, christian.heimes, benjamin.peterson, tarek, eric.araujo, grahamd, python-dev
2011-04-25 21:51:09vstinnersetmessageid: <1303768269.04.0.928915307898.issue10914@psf.upfronthosting.co.za>
2011-04-25 21:51:08vstinnerlinkissue10914 messages
2011-04-25 21:51:08vstinnercreate