Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ Erik Demaine
Jeroen Demeyer
Martin Dengler
John Dennis
Chris Denton
L. Peter Deutsch
Roger Dev
Philippe Devalkeneer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes import error when running Python from a network drive
21 changes: 17 additions & 4 deletions Modules/getpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,11 +540,24 @@ getpath_realpath(PyObject *Py_UNUSED(self) , PyObject *args)
PyErr_SetFromWindowsErr(err);
result = NULL;
} else if (len <= MAXPATHLEN) {
const wchar_t *p = resolved;
wchar_t *p = resolved;
if (0 == wcsncmp(p, L"\\\\?\\", 4)) {
if (GetFileAttributesW(&p[4]) != INVALID_FILE_ATTRIBUTES) {
p += 4;
len -= 4;
if (0 == wcsncmp(&p[4], L"UNC\\", 4)) {
// A \\?\UNC\ path. Try converting to a \\ path.
p[6] = L'\\';
if (GetFileAttributesW(&p[6]) != INVALID_FILE_ATTRIBUTES) {
p += 6;
len -= 6;
} else {
// Change back to a \\?\UNC\ path.
p[6] = L'C';
}
} else {
// Maybe a drive path like \\?\C:\. Try stripping the prefix.
if (GetFileAttributesW(&p[4]) != INVALID_FILE_ATTRIBUTES) {
p += 4;
len -= 4;
}
}
}
if (CompareStringOrdinal(path, (int)pathlen, p, len, TRUE) == CSTR_EQUAL) {
Expand Down
Loading