diff options
| author | Itai Steinherz <itaisteinherz@gmail.com> | 2022-05-03 02:19:13 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-03 00:19:13 +0100 |
| commit | 39e6b8ae6a5b49bb23746fdcc354d148ff2d98e3 (patch) | |
| tree | 0744e51c145b37baa6335749d890bd1efba5f19f /Modules | |
| parent | ebb8b512e959ca1a0a506ac0f0faf461b1b2ff85 (diff) | |
| download | cpython-git-39e6b8ae6a5b49bb23746fdcc354d148ff2d98e3.tar.gz | |
bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858)
Diffstat (limited to 'Modules')
| -rw-r--r-- | Modules/posixmodule.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index a2ea507996..a7f5780468 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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) { |
