mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +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:
commit
91ecea24f5
4 changed files with 14 additions and 19 deletions
|
@ -500,7 +500,12 @@ class WalkTests(unittest.TestCase):
|
|||
f.write("I'm " + path + " and proud of it. Blame test_os.\n")
|
||||
f.close()
|
||||
if support.can_symlink():
|
||||
os.symlink(os.path.abspath(t2_path), link_path)
|
||||
if os.name == 'nt':
|
||||
def symlink_to_dir(src, dest):
|
||||
os.symlink(src, dest, True)
|
||||
else:
|
||||
symlink_to_dir = os.symlink
|
||||
symlink_to_dir(os.path.abspath(t2_path), link_path)
|
||||
sub2_tree = (sub2_path, ["link"], ["tmp3"])
|
||||
else:
|
||||
sub2_tree = (sub2_path, [], ["tmp3"])
|
||||
|
@ -1131,7 +1136,7 @@ class Win32SymlinkTests(unittest.TestCase):
|
|||
os.remove(self.missing_link)
|
||||
|
||||
def test_directory_link(self):
|
||||
os.symlink(self.dirlink_target, self.dirlink)
|
||||
os.symlink(self.dirlink_target, self.dirlink, True)
|
||||
self.assertTrue(os.path.exists(self.dirlink))
|
||||
self.assertTrue(os.path.isdir(self.dirlink))
|
||||
self.assertTrue(os.path.islink(self.dirlink))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue