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:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user