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 Arfrever, benjamin.peterson, ezio.melotti, gregory.p.smith, lemburg, loewis, pitrou, vstinner
Date 2010-05-14.16:53:50
SpamBayes Score 4.42633e-06
Marked as misclassified No
Message-id <1273856034.98.0.139429807226.issue8715@psf.upfronthosting.co.za>
In-reply-to
Content
PyUnicode_EncodeFSDefault() is the opposite of PyUnicode_DecodeFSDefault(AndSize)() and is similar to the new function os.fsencode(). As you can see in the patch, it simplifies many functions.

/* Encodes a Unicode object to Py_FileSystemDefaultEncoding with the
   "surrogateescape" error handler and returns a bytes object.

   If Py_FileSystemDefaultEncoding is not set, fall back to UTF-8.
*/

PyAPI_FUNC(PyObject*) PyUnicode_EncodeFSDefault(
    PyObject *unicode
    );

The function unify the behaviour when Py_FileSystemDefaultEncoding is NULL: use UTF-8 whereas import uses ASCII. Other functions did already fall back to UTF-8: PyUnicode_AsEncodedString() uses PyUnicode_GetDefaultEncoding() (hardcoded to utf8 in Python3) if encoding is NULL

The patch does also fix tkinter module initializer (use surrogateescape error handler, instead of strict).

The patch was first attached to issue #8611.
History
Date User Action Args
2010-05-14 16:53:55vstinnersetrecipients: + vstinner, lemburg, loewis, gregory.p.smith, pitrou, benjamin.peterson, ezio.melotti, Arfrever
2010-05-14 16:53:54vstinnersetmessageid: <1273856034.98.0.139429807226.issue8715@psf.upfronthosting.co.za>
2010-05-14 16:53:52vstinnerlinkissue8715 messages
2010-05-14 16:53:51vstinnercreate