Issue #5913: os.listdir() should fail for empty path on windows.
This commit is contained in:
parent
eeb51a99c5
commit
406d7aaee7
|
@ -266,6 +266,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #5913: os.listdir() should fail for empty path on windows.
|
||||||
|
|
||||||
- Issue #5084: unpickling now interns the attribute names of pickled objects,
|
- Issue #5084: unpickling now interns the attribute names of pickled objects,
|
||||||
saving memory and avoiding growth in size of subsequent pickles. Proposal
|
saving memory and avoiding growth in size of subsequent pickles. Proposal
|
||||||
and original patch by Jake McGuire.
|
and original patch by Jake McGuire.
|
||||||
|
|
|
@ -2183,7 +2183,6 @@ posix_listdir(PyObject *self, PyObject *args)
|
||||||
if (PyArg_ParseTuple(args, "U:listdir", &po)) {
|
if (PyArg_ParseTuple(args, "U:listdir", &po)) {
|
||||||
WIN32_FIND_DATAW wFileData;
|
WIN32_FIND_DATAW wFileData;
|
||||||
Py_UNICODE *wnamebuf;
|
Py_UNICODE *wnamebuf;
|
||||||
Py_UNICODE wch;
|
|
||||||
/* Overallocate for \\*.*\0 */
|
/* Overallocate for \\*.*\0 */
|
||||||
len = PyUnicode_GET_SIZE(po);
|
len = PyUnicode_GET_SIZE(po);
|
||||||
wnamebuf = malloc((len + 5) * sizeof(wchar_t));
|
wnamebuf = malloc((len + 5) * sizeof(wchar_t));
|
||||||
|
@ -2192,10 +2191,12 @@ posix_listdir(PyObject *self, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
wcscpy(wnamebuf, PyUnicode_AS_UNICODE(po));
|
wcscpy(wnamebuf, PyUnicode_AS_UNICODE(po));
|
||||||
wch = len > 0 ? wnamebuf[len-1] : '\0';
|
if (len > 0) {
|
||||||
if (wch != L'/' && wch != L'\\' && wch != L':')
|
Py_UNICODE wch = wnamebuf[len-1];
|
||||||
wnamebuf[len++] = L'\\';
|
if (wch != L'/' && wch != L'\\' && wch != L':')
|
||||||
wcscpy(wnamebuf + len, L"*.*");
|
wnamebuf[len++] = L'\\';
|
||||||
|
wcscpy(wnamebuf + len, L"*.*");
|
||||||
|
}
|
||||||
if ((d = PyList_New(0)) == NULL) {
|
if ((d = PyList_New(0)) == NULL) {
|
||||||
free(wnamebuf);
|
free(wnamebuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2266,8 +2267,8 @@ posix_listdir(PyObject *self, PyObject *args)
|
||||||
char ch = namebuf[len-1];
|
char ch = namebuf[len-1];
|
||||||
if (ch != SEP && ch != ALTSEP && ch != ':')
|
if (ch != SEP && ch != ALTSEP && ch != ':')
|
||||||
namebuf[len++] = '/';
|
namebuf[len++] = '/';
|
||||||
|
strcpy(namebuf + len, "*.*");
|
||||||
}
|
}
|
||||||
strcpy(namebuf + len, "*.*");
|
|
||||||
|
|
||||||
if ((d = PyList_New(0)) == NULL)
|
if ((d = PyList_New(0)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue