os.listdir(): Fall back to the original byte string if conversion to unicode

fails, as discussed in patch #683592.
This commit is contained in:
Just van Rossum 2003-03-04 19:30:44 +00:00
parent 69700ef573
commit 6a42183967
1 changed files with 8 additions and 6 deletions

View File

@ -1809,12 +1809,14 @@ posix_listdir(PyObject *self, PyObject *args)
w = PyUnicode_FromEncodedObject(v, w = PyUnicode_FromEncodedObject(v,
Py_FileSystemDefaultEncoding, Py_FileSystemDefaultEncoding,
"strict"); "strict");
Py_DECREF(v); if (w != NULL) {
v = w; Py_DECREF(v);
if (v == NULL) { v = w;
Py_DECREF(d); }
d = NULL; else {
break; /* fall back to the original byte string, as
discussed in patch #683592 */
PyErr_Clear();
} }
} }
#endif #endif