Mercurial > cpython-lru_cache-weakref
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 59992:c3c34f847998 | 59995:030962092373 |
|---|---|
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 int | 29 int |
| 30 _Py_SetFileSystemEncoding(PyObject *s) | 30 _Py_SetFileSystemEncoding(PyObject *s) |
| 31 { | 31 { |
| 32 PyObject *defenc; | 32 PyObject *defenc, *codec; |
| 33 if (!PyUnicode_Check(s)) { | 33 if (!PyUnicode_Check(s)) { |
| 34 PyErr_BadInternalCall(); | 34 PyErr_BadInternalCall(); |
| 35 return -1; | 35 return -1; |
| 36 } | 36 } |
| 37 defenc = _PyUnicode_AsDefaultEncodedString(s, NULL); | 37 defenc = _PyUnicode_AsDefaultEncodedString(s, NULL); |
| 38 if (!defenc) | 38 if (!defenc) |
| 39 return -1; | 39 return -1; |
| 40 codec = _PyCodec_Lookup(PyBytes_AsString(defenc)); | |
| 41 if (codec == NULL) | |
| 42 return -1; | |
| 43 Py_DECREF(codec); | |
| 40 if (!Py_HasFileSystemDefaultEncoding && Py_FileSystemDefaultEncoding) | 44 if (!Py_HasFileSystemDefaultEncoding && Py_FileSystemDefaultEncoding) |
| 41 /* A file system encoding was set at run-time */ | 45 /* A file system encoding was set at run-time */ |
| 42 free((char*)Py_FileSystemDefaultEncoding); | 46 free((char*)Py_FileSystemDefaultEncoding); |
| 43 Py_FileSystemDefaultEncoding = strdup(PyBytes_AsString(defenc)); | 47 Py_FileSystemDefaultEncoding = strdup(PyBytes_AsString(defenc)); |
| 44 Py_HasFileSystemDefaultEncoding = 0; | 48 Py_HasFileSystemDefaultEncoding = 0; |
