diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-03-25 00:30:28 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-03-25 00:30:28 (GMT) |
commit | 120c21227af4e54ec181da8fce6ae21b414aa2d0 (patch) | |
tree | db310baf83e83a53241bcce9eca19b9d4ed336e8 /Python | |
parent | cd4ec0e2734a4f59ba97a79cf54c2c161167b96f (diff) | |
download | cpython-120c21227af4e54ec181da8fce6ae21b414aa2d0.zip cpython-120c21227af4e54ec181da8fce6ae21b414aa2d0.tar.gz cpython-120c21227af4e54ec181da8fce6ae21b414aa2d0.tar.bz2 |
Issue #8226: sys.setfilesystemencoding() raises a LookupError if the encoding
is unknown.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index a928fc4..6b8600b 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -29,7 +29,7 @@ int Py_HasFileSystemDefaultEncoding = 0; int _Py_SetFileSystemEncoding(PyObject *s) { - PyObject *defenc; + PyObject *defenc, *codec; if (!PyUnicode_Check(s)) { PyErr_BadInternalCall(); return -1; @@ -37,6 +37,10 @@ _Py_SetFileSystemEncoding(PyObject *s) 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); |