mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
#1669: don't allow shutil.rmtree() to be called on a symlink.
This commit is contained in:
parent
56112895d6
commit
5235398323
4 changed files with 42 additions and 11 deletions
|
@ -149,6 +149,20 @@ class TestShutil(unittest.TestCase):
|
|||
except OSError:
|
||||
pass
|
||||
|
||||
def test_rmtree_on_symlink(self):
|
||||
# bug 1669.
|
||||
os.mkdir(TESTFN)
|
||||
try:
|
||||
src = os.path.join(TESTFN, 'cheese')
|
||||
dst = os.path.join(TESTFN, 'shop')
|
||||
os.mkdir(src)
|
||||
os.symlink(src, dst)
|
||||
self.assertRaises(OSError, shutil.rmtree, dst)
|
||||
finally:
|
||||
shutil.rmtree(TESTFN, ignore_errors=True)
|
||||
|
||||
|
||||
|
||||
def test_main():
|
||||
test_support.run_unittest(TestShutil)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue