summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorJust van Rossum <just@letterror.com>2003-03-04 19:30:44 (GMT)
committerJust van Rossum <just@letterror.com>2003-03-04 19:30:44 (GMT)
commit6a421839676a4c946ccb1280baae31175fc85253 (patch)
tree263de07a0ee735ee0d3473badc627f27a914bfc3 /Modules
parent69700ef5735eeb6b5ef456e8dd30e1f146dae8bd (diff)
downloadcpython-6a421839676a4c946ccb1280baae31175fc85253.zip
cpython-6a421839676a4c946ccb1280baae31175fc85253.tar.gz
cpython-6a421839676a4c946ccb1280baae31175fc85253.tar.bz2
os.listdir(): Fall back to the original byte string if conversion to unicode
fails, as discussed in patch #683592.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c14
1 files 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