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:
Antoine Pitrou 2012-01-24 09:05:18 +01:00
commit 91ecea24f5
4 changed files with 14 additions and 19 deletions

View file

@ -6551,7 +6551,6 @@ win_symlink(PyObject *self, PyObject *args, PyObject *kwargs)
wchar_t *wsrc, *wdest;
int target_is_directory = 0;
DWORD res;
WIN32_FILE_ATTRIBUTE_DATA src_info;
if (!check_CreateSymbolicLinkW())
{
@ -6581,16 +6580,6 @@ win_symlink(PyObject *self, PyObject *args, PyObject *kwargs)
if (wsrc == NULL)
goto error;
/* if src is a directory, ensure target_is_directory==1 */
if(
GetFileAttributesExW(
wsrc, GetFileExInfoStandard, &src_info
))
{
target_is_directory = target_is_directory ||
(src_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
}
Py_BEGIN_ALLOW_THREADS
res = Py_CreateSymbolicLinkW(wdest, wsrc, target_is_directory);
Py_END_ALLOW_THREADS