diff options
-rw-r--r-- | Modules/posixmodule.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index cc922725d7..713729a8af 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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 |