mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
bpo-46362: Ensure ntpath.abspath() uses the Windows API correctly (GH-30571)
This makes ntpath.abspath()/getpath_abspath() follow normpath(), since some WinAPIs such as PathCchSkipRoot() require backslashed paths.
This commit is contained in:
parent
b8ddf7e794
commit
d4e64cd4b0
8 changed files with 114 additions and 42 deletions
|
|
@ -59,7 +59,7 @@ getpath_abspath(PyObject *Py_UNUSED(self), PyObject *args)
|
|||
{
|
||||
PyObject *r = NULL;
|
||||
PyObject *pathobj;
|
||||
const wchar_t *path;
|
||||
wchar_t *path;
|
||||
if (!PyArg_ParseTuple(args, "U", &pathobj)) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -67,8 +67,8 @@ getpath_abspath(PyObject *Py_UNUSED(self), PyObject *args)
|
|||
path = PyUnicode_AsWideCharString(pathobj, &len);
|
||||
if (path) {
|
||||
wchar_t *abs;
|
||||
if (_Py_abspath(path, &abs) == 0 && abs) {
|
||||
r = PyUnicode_FromWideChar(_Py_normpath(abs, -1), -1);
|
||||
if (_Py_abspath((const wchar_t *)_Py_normpath(path, -1), &abs) == 0 && abs) {
|
||||
r = PyUnicode_FromWideChar(abs, -1);
|
||||
PyMem_RawFree((void *)abs);
|
||||
} else {
|
||||
PyErr_SetString(PyExc_OSError, "failed to make path absolute");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue