Commit 6a421839 authored by Just van Rossum's avatar Just van Rossum

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

fails, as discussed in patch #683592.
parent 69700ef5
......@@ -1809,12 +1809,14 @@ posix_listdir(PyObject *self, PyObject *args)
w = PyUnicode_FromEncodedObject(v,
Py_FileSystemDefaultEncoding,
"strict");
Py_DECREF(v);
v = w;
if (v == NULL) {
Py_DECREF(d);
d = NULL;
break;
if (w != NULL) {
Py_DECREF(v);
v = w;
}
else {
/* fall back to the original byte string, as
discussed in patch #683592 */
PyErr_Clear();
}
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment