Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove realpath branch in getpath - the readlink code before is alway…
…s taking precedence
  • Loading branch information
pelson committed Jan 15, 2025
commit b30c594d5c74daf4707ba64157bee92593148151
31 changes: 0 additions & 31 deletions Modules/getpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,37 +478,6 @@ getpath_realpath(PyObject *Py_UNUSED(self) , PyObject *args)
PyMem_RawFree((void *)path);
return r;

#elif defined(HAVE_REALPATH)
PyObject *r = NULL;
struct stat st;
const char *narrow = NULL;
wchar_t *path = PyUnicode_AsWideCharString(pathobj, NULL);
if (!path) {
goto done;
}
narrow = Py_EncodeLocale(path, NULL);
if (!narrow) {
PyErr_NoMemory();
goto done;
}
if (lstat(narrow, &st)) {
PyErr_SetFromErrno(PyExc_OSError);
goto done;
}
if (!S_ISLNK(st.st_mode)) {
r = Py_NewRef(pathobj);
goto done;
}
wchar_t resolved[MAXPATHLEN+1];
if (_Py_wrealpath(path, resolved, MAXPATHLEN) == NULL) {
PyErr_SetFromErrno(PyExc_OSError);
} else {
r = PyUnicode_FromWideChar(resolved, -1);
}
done:
PyMem_Free((void *)path);
PyMem_Free((void *)narrow);
return r;
#elif defined(MS_WINDOWS)
HANDLE hFile;
wchar_t resolved[MAXPATHLEN+1];
Expand Down