mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +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
|
@ -156,6 +156,14 @@ def rmtree(path, ignore_errors=False, onerror=None):
|
|||
elif onerror is None:
|
||||
def onerror(*args):
|
||||
raise
|
||||
try:
|
||||
if os.path.islink(path):
|
||||
# symlinks to directories are forbidden, see bug #1669
|
||||
raise OSError("Cannot call rmtree on a symbolic link")
|
||||
except OSError:
|
||||
onerror(os.path.islink, path, sys.exc_info())
|
||||
# can't continue even if onerror hook returns
|
||||
return
|
||||
names = []
|
||||
try:
|
||||
names = os.listdir(path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue