diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-03-25 00:35:51 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-03-25 00:35:51 (GMT) |
commit | d8805b2bb8f5e25641153776c6a01c5653417ec9 (patch) | |
tree | 43cabe2b2863ce8cddc2c1707ac75a0e4fac0cf1 /Python/bltinmodule.c | |
parent | 2f927fc61b56ba55548d71070bf73f3bb1d2b86a (diff) | |
download | cpython-d8805b2bb8f5e25641153776c6a01c5653417ec9.zip cpython-d8805b2bb8f5e25641153776c6a01c5653417ec9.tar.gz cpython-d8805b2bb8f5e25641153776c6a01c5653417ec9.tar.bz2 |
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.
........
Diffstat (limited to 'Python/bltinmodule.c')
-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 069d790..10527c1 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); |