diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-15 16:27:27 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-15 16:27:27 (GMT) |
commit | ae6265f8d06dbec7d08c73ca23dad0f040d09b8e (patch) | |
tree | 3598426233e690b284bce322194f51be94ab6799 /Python/import.c | |
parent | 59e62db0a39eb89930ed3ae1730726cd15b7d640 (diff) | |
download | cpython-ae6265f8d06dbec7d08c73ca23dad0f040d09b8e.zip cpython-ae6265f8d06dbec7d08c73ca23dad0f040d09b8e.tar.gz cpython-ae6265f8d06dbec7d08c73ca23dad0f040d09b8e.tar.bz2 |
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.
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/Python/import.c b/Python/import.c index 923888d..d23eb6a 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1633,8 +1633,7 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf, if (!v) return NULL; if (PyUnicode_Check(v)) { - v = PyUnicode_AsEncodedString(v, - Py_FileSystemDefaultEncoding, NULL); + v = PyUnicode_EncodeFSDefault(v); if (v == NULL) return NULL; } @@ -2752,14 +2751,7 @@ ensure_fromlist(PyObject *mod, PyObject *fromlist, char *buf, Py_ssize_t buflen, char *subname; PyObject *submod; char *p; - if (!Py_FileSystemDefaultEncoding) { - item8 = PyUnicode_EncodeASCII(PyUnicode_AsUnicode(item), - PyUnicode_GetSize(item), - NULL); - } else { - item8 = PyUnicode_AsEncodedString(item, - Py_FileSystemDefaultEncoding, NULL); - } + item8 = PyUnicode_EncodeFSDefault(item); if (!item8) { PyErr_SetString(PyExc_ValueError, "Cannot encode path item"); return 0; |