Raghuram Devarakonda added the comment:
I am ok with disallowing symlinks in rmtree() because if it were to be
allowed, the semantics are not clear. In addition, neither 'rmdir' nor
'rm -rf' delete the target directory.
The attached patch would raise error if symbolic link is passed to
rmtree. Even though there is a parameter 'ignore_errors", I don't think
it should be used in suppressing symbolic link error. Comments?
Added file: http://bugs.python.org/file9015/rmtree.diff
__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1669>
__________________________________
Index: Lib/shutil.py
===================================================================
--- Lib/shutil.py (revision 59581)
+++ Lib/shutil.py (working copy)
@@ -140,7 +140,8 @@
raise Error, errors
def rmtree(path, ignore_errors=False, onerror=None):
- """Recursively delete a directory tree.
+ """Recursively delete a directory tree. Fail if path is symbolic
+ link.
If ignore_errors is set, errors are ignored; otherwise, if onerror
is set, it is called to handle the error with arguments (func,
@@ -150,6 +151,10 @@
is false and onerror is None, an exception is raised.
"""
+
+ if os.path.islink(path):
+ raise ValueError('path can not be symbolic link')
+
if ignore_errors:
def onerror(*args):
pass
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com