mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #13772: In os.symlink() under Windows, do not try to guess the link
target's type (file or directory). The detection was buggy and made the call non-atomic (therefore prone to race conditions).
This commit is contained in:
parent
3b65fd7e97
commit
5311c1d7ab
4 changed files with 14 additions and 19 deletions
|
@ -5330,7 +5330,6 @@ win_symlink(PyObject *self, PyObject *args, PyObject *kwargs)
|
|||
PyObject *src, *dest;
|
||||
int target_is_directory = 0;
|
||||
DWORD res;
|
||||
WIN32_FILE_ATTRIBUTE_DATA src_info;
|
||||
|
||||
if (!check_CreateSymbolicLinkW())
|
||||
{
|
||||
|
@ -5351,16 +5350,6 @@ win_symlink(PyObject *self, PyObject *args, PyObject *kwargs)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* if src is a directory, ensure target_is_directory==1 */
|
||||
if(
|
||||
GetFileAttributesExW(
|
||||
PyUnicode_AsUnicode(src), GetFileExInfoStandard, &src_info
|
||||
))
|
||||
{
|
||||
target_is_directory = target_is_directory ||
|
||||
(src_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
|
||||
}
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
res = Py_CreateSymbolicLinkW(
|
||||
PyUnicode_AsUnicode(dest),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue