]> granicus.if.org Git - python/commitdiff
os.listdir(): Fall back to the original byte string if conversion to unicode
authorJust van Rossum <just@letterror.com>
Tue, 4 Mar 2003 19:30:44 +0000 (19:30 +0000)
committerJust van Rossum <just@letterror.com>
Tue, 4 Mar 2003 19:30:44 +0000 (19:30 +0000)
fails, as discussed in patch #683592.

Modules/posixmodule.c

index cc922725d7fa08a35282bec0721fd830e516f579..713729a8af71c0fc7f7f5e10a2e6a8da4d50746c 100644 (file)
@@ -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