Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 59994:e8b08d773e78
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:30:28 +0000 |
| parents | 88f147d26372 |
| children | cab14be0ada1 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Wed Mar 24 23:07:31 2010 +0000 +++ b/Python/bltinmodule.c Thu Mar 25 00:30:28 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);
