Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 59995:030962092373 3.1
Merged revisions 79393 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r79393 | victor.stinner | 2010-03-25 01:30:28 +0100 (jeu., 25 mars 2010) | 3 lines
Issue #8226: sys.setfilesystemencoding() raises a LookupError if the encoding
is unknown.
........
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Thu, 25 Mar 2010 00:35:51 +0000 |
| parents | a9e1f1d34c96 |
| children | f197407bdba2 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Wed Mar 24 23:13:42 2010 +0000 +++ b/Python/bltinmodule.c Thu Mar 25 00:35:51 2010 +0000 @@ -29,7 +29,7 @@ int _Py_SetFileSystemEncoding(PyObject *s) { - PyObject *defenc; + PyObject *defenc, *codec; if (!PyUnicode_Check(s)) { PyErr_BadInternalCall(); return -1; @@ -37,6 +37,10 @@ defenc = _PyUnicode_AsDefaultEncodedString(s, NULL); if (!defenc) return -1; + codec = _PyCodec_Lookup(PyBytes_AsString(defenc)); + if (codec == NULL) + return -1; + Py_DECREF(codec); if (!Py_HasFileSystemDefaultEncoding && Py_FileSystemDefaultEncoding) /* A file system encoding was set at run-time */ free((char*)Py_FileSystemDefaultEncoding);
