diff options
author | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2002-03-22 20:51:58 (GMT) |
---|---|---|
committer | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2002-03-22 20:51:58 (GMT) |
commit | 94b866a03088da6257823c74a71b4d0760c60bbb (patch) | |
tree | 8f3ce2a309d4ed78a5e3639bc0d225a492efc9a5 /Modules/posixmodule.c | |
parent | 398b9f6d6d75628efe03fb4d8dc1aa2df6c35a67 (diff) | |
download | cpython-94b866a03088da6257823c74a71b4d0760c60bbb.zip cpython-94b866a03088da6257823c74a71b4d0760c60bbb.tar.gz cpython-94b866a03088da6257823c74a71b4d0760c60bbb.tar.bz2 |
Handle os.listdir("") case correctly on Windows. Closes bug 500705.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 4d9408a..46e145f 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -980,14 +980,15 @@ posix_listdir(PyObject *self, PyObject *args) char namebuf[MAX_PATH*2+5]; char *bufptr = namebuf; int len = sizeof(namebuf)/sizeof(namebuf[0]); - char ch; if (!PyArg_ParseTuple(args, "et#:listdir", Py_FileSystemDefaultEncoding, &bufptr, &len)) return NULL; - ch = namebuf[len-1]; - if (ch != SEP && ch != ALTSEP && ch != ':') - namebuf[len++] = '/'; + if (len > 0) { + char ch = namebuf[len-1]; + if (ch != SEP && ch != ALTSEP && ch != ':') + namebuf[len++] = '/'; + } strcpy(namebuf + len, "*.*"); if ((d = PyList_New(0)) == NULL) |