Kaydet (Commit) 94b866a0 authored tarafından Neil Schemenauer's avatar Neil Schemenauer

Handle os.listdir("") case correctly on Windows. Closes bug 500705.

üst 398b9f6d
...@@ -980,14 +980,15 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -980,14 +980,15 @@ posix_listdir(PyObject *self, PyObject *args)
char namebuf[MAX_PATH*2+5]; char namebuf[MAX_PATH*2+5];
char *bufptr = namebuf; char *bufptr = namebuf;
int len = sizeof(namebuf)/sizeof(namebuf[0]); int len = sizeof(namebuf)/sizeof(namebuf[0]);
char ch;
if (!PyArg_ParseTuple(args, "et#:listdir", if (!PyArg_ParseTuple(args, "et#:listdir",
Py_FileSystemDefaultEncoding, &bufptr, &len)) Py_FileSystemDefaultEncoding, &bufptr, &len))
return NULL; return NULL;
ch = namebuf[len-1]; if (len > 0) {
if (ch != SEP && ch != ALTSEP && ch != ':') char ch = namebuf[len-1];
namebuf[len++] = '/'; if (ch != SEP && ch != ALTSEP && ch != ':')
namebuf[len++] = '/';
}
strcpy(namebuf + len, "*.*"); strcpy(namebuf + len, "*.*");
if ((d = PyList_New(0)) == NULL) if ((d = PyList_New(0)) == NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment