mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #4071: ntpath.abspath returned an empty string for long unicode path.
This commit is contained in:
parent
3d6f8ff81f
commit
ed29bb49f8
1 changed files with 20 additions and 6 deletions
|
@ -2389,13 +2389,27 @@ posix__getfullpathname(PyObject *self, PyObject *args)
|
||||||
if (unicode_file_names()) {
|
if (unicode_file_names()) {
|
||||||
PyUnicodeObject *po;
|
PyUnicodeObject *po;
|
||||||
if (PyArg_ParseTuple(args, "U|:_getfullpathname", &po)) {
|
if (PyArg_ParseTuple(args, "U|:_getfullpathname", &po)) {
|
||||||
Py_UNICODE woutbuf[MAX_PATH*2];
|
Py_UNICODE *wpath = PyUnicode_AS_UNICODE(po);
|
||||||
|
Py_UNICODE woutbuf[MAX_PATH*2], *woutbufp = woutbuf;
|
||||||
Py_UNICODE *wtemp;
|
Py_UNICODE *wtemp;
|
||||||
if (!GetFullPathNameW(PyUnicode_AS_UNICODE(po),
|
DWORD result;
|
||||||
sizeof(woutbuf)/sizeof(woutbuf[0]),
|
PyObject *v;
|
||||||
woutbuf, &wtemp))
|
result = GetFullPathNameW(wpath,
|
||||||
return win32_error("GetFullPathName", "");
|
sizeof(woutbuf)/sizeof(woutbuf[0]),
|
||||||
return PyUnicode_FromUnicode(woutbuf, wcslen(woutbuf));
|
woutbuf, &wtemp);
|
||||||
|
if (result > sizeof(woutbuf)/sizeof(woutbuf[0])) {
|
||||||
|
woutbufp = malloc(result * sizeof(Py_UNICODE));
|
||||||
|
if (!woutbufp)
|
||||||
|
return PyErr_NoMemory();
|
||||||
|
result = GetFullPathNameW(wpath, result, woutbufp, &wtemp);
|
||||||
|
}
|
||||||
|
if (result)
|
||||||
|
v = PyUnicode_FromUnicode(woutbufp, wcslen(woutbufp));
|
||||||
|
else
|
||||||
|
v = win32_error_unicode("GetFullPathNameW", wpath);
|
||||||
|
if (woutbufp != woutbuf)
|
||||||
|
free(woutbufp);
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
/* Drop the argument parsing error as narrow strings
|
/* Drop the argument parsing error as narrow strings
|
||||||
are also valid. */
|
are also valid. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue