Skip to content

Commit 5a6ab7c

Browse files
committed
Match CPython Windows stat fallback semantics
1 parent 1c6fbc4 commit 5a6ab7c

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

  • graalpython/python-libposix/src

‎graalpython/python-libposix/src/posix.c‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,11 +769,25 @@ static int stat_path_attributes_to_longs(const wchar_t *path, int64_t *out) {
769769
info.ftLastAccessTime, info.ftLastWriteTime, info.ftCreationTime, out);
770770
return 0;
771771
}
772+
DWORD error = GetLastError();
773+
if (error != ERROR_ACCESS_DENIED && error != ERROR_SHARING_VIOLATION) {
774+
set_win_errno(error);
775+
return -1;
776+
}
772777

773778
WIN32_FIND_DATAW findInfo;
774779
HANDLE findHandle = FindFirstFileW(path, &findInfo);
775780
if (findHandle == INVALID_HANDLE_VALUE) {
776-
set_win_errno(GetLastError());
781+
DWORD findError = GetLastError();
782+
switch (findError) {
783+
case ERROR_FILE_NOT_FOUND:
784+
case ERROR_PATH_NOT_FOUND:
785+
case ERROR_NOT_READY:
786+
case ERROR_BAD_NET_NAME:
787+
error = findError;
788+
break;
789+
}
790+
set_win_errno(error);
777791
return -1;
778792
}
779793
stat_attributes_to_longs(findInfo.dwFileAttributes, findInfo.nFileSizeHigh, findInfo.nFileSizeLow,

0 commit comments

Comments
 (0)