mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858)
This commit is contained in:
parent
ebb8b512e9
commit
39e6b8ae6a
4 changed files with 57 additions and 1 deletions
|
@ -1890,7 +1890,17 @@ win32_xstat_impl(const wchar_t *path, struct _Py_stat_struct *result,
|
|||
/* Try reading the parent directory. */
|
||||
if (!attributes_from_dir(path, &fileInfo, &tagInfo.ReparseTag)) {
|
||||
/* Cannot read the parent directory. */
|
||||
SetLastError(error);
|
||||
switch (GetLastError()) {
|
||||
case ERROR_FILE_NOT_FOUND: /* File cannot be found */
|
||||
case ERROR_PATH_NOT_FOUND: /* File parent directory cannot be found */
|
||||
case ERROR_NOT_READY: /* Drive exists but unavailable */
|
||||
case ERROR_BAD_NET_NAME: /* Remote drive unavailable */
|
||||
break;
|
||||
/* Restore the error from CreateFileW(). */
|
||||
default:
|
||||
SetLastError(error);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue