[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions
report at bugs.python.org
Thu Apr 29 16:11:27 CEST 2010
Tarek Ziadé <ziade.tarek at gmail.com> added the comment:
> Well, I don't think removing the current onerror support is a viable
> option for backward compatibility reasons,
> so we might as well fix it.
The options could be deprecated since the new behavior would *return* errors.
> Do you have some use cases in mind, Tarek?
What I have in mind is robustness and simplicity:
robustness because rmtree() will stop calling third party code that can possibly fail and blow the whole process, while working at removing the tree.
Simplicity because, if it fails at removing some files using the usual os.* APIs, it will just return these errors.
Having this two phases-process will ensure that rmtree() did all that was possible to remove files.
And as I said previously, I am curious to know what is going to be done in the onerror() function when something fails in rmtree(). I doubt any third-party code will do better.
This statement "I couldn't copy this file, try it yourself" seems doomed to complexity.
If the only use case for onerror() is to silent failures, returning these failures seem quite enough. Ala smtp when you get back a list of mails that couldn't be send: it doesn't ask you to send them by yourself, just informs you.
Now maybe we do miss some APIs to check for a file tree sanity, like:
- are the permissions the same throughout the tree ?
- is there any link that will make rmtree() fail ?
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list