Issue #8715: Create PyUnicode_EncodeFSDefault() function: Encode a Unicode

object to Py_FileSystemDefaultEncoding with the "surrogateescape" error
handler, return a bytes object. If Py_FileSystemDefaultEncoding is not set,
fall back to UTF-8.
This commit is contained in:
Victor Stinner 2010-05-15 16:27:27 +00:00
parent 59e62db0a3
commit ae6265f8d0
10 changed files with 46 additions and 26 deletions

View file

@ -247,8 +247,7 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
if (u == NULL)
return -1;
stringobj = PyUnicode_AsEncodedString(
u, Py_FileSystemDefaultEncoding, "surrogateescape");
stringobj = PyUnicode_EncodeFSDefault(u);
Py_DECREF(u);
if (stringobj == NULL)
return -1;