From: Just van Rossum Date: Tue, 4 Mar 2003 19:30:44 +0000 (+0000) Subject: os.listdir(): Fall back to the original byte string if conversion to unicode X-Git-Tag: v2.3c1~1591 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6a421839676a4c946ccb1280baae31175fc85253;p=thirdparty%2FPython%2Fcpython.git os.listdir(): Fall back to the original byte string if conversion to unicode fails, as discussed in patch #683592. --- diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index cc922725d7fa..713729a8af71 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