From 6a421839676a4c946ccb1280baae31175fc85253 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Tue, 4 Mar 2003 19:30:44 +0000 Subject: os.listdir(): Fall back to the original byte string if conversion to unicode fails, as discussed in patch #683592. --- Modules/posixmodule.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index cc922725..713729a 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 -- cgit v0.12