[issue1669] shutil.rmtree fails on symlink, after deleting contents
Raghuram Devarakonda
report at bugs.python.org
Thu Dec 20 20:45:45 CET 2007
Raghuram Devarakonda added the comment:
Index: Lib/shutil.py
===================================================================
--- Lib/shutil.py (revision 59581)
+++ Lib/shutil.py (working copy)
@@ -156,6 +156,16 @@
elif onerror is None:
def onerror(*args):
raise
+
+ try:
+ if os.path.islink(path):
+ if ignore_errors:
+ return
+ else:
+ raise IOError('path can not be symbolic link')
+ except IOError, err:
+ onerror(os.path.islink, path, sys.exc_info())
+
names = []
try:
names = os.listdir(path)
-------------------
How does this look? The error handling is slightly different for this
case because it can not continue if 'ignore_errors' is True. I will
update the doc if the code change is ok.
On Dec 20, 2007 12:43 PM, Guido van Rossum <report at bugs.python.org> wrote:
>
> Guido van Rossum added the comment:
>
> Thanks for the patch. I think it should raise IOError, not ValueError,
> and it should use the onerror() handling used for all other errors.
> Also, can you include an update for the docs in the Doc tree?
>
>
> __________________________________
> Tracker <report at bugs.python.org>
> <http://bugs.python.org/issue1669>
> __________________________________
>
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1669>
__________________________________
More information about the Python-bugs-list
mailing list