This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Propose to deprecate `ignore_errors` and `onerror` parameters of `shutil.rmtree()`
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Marco Sulla, giampaolo.rodola, rhettinger, serhiy.storchaka, tarek
Priority: normal Keywords:

Created on 2019-08-08 08:20 by Marco Sulla, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg349223 - (view) Author: Marco Sulla (Marco Sulla) * Date: 2019-08-08 08:35
I propose to mark as deprecated the parameters `ignore_errors` and `onerror` of `shutil.rmtree()`, and raise a warning if used.

The reason is I feel them unpythonic. For emulating `ignore_errors=True`, the code can be written simply with a `try-except` that passes by default all `OSError`s . The `ignore_errors=True, onerror=myHandler` case can written simply with a `try-except` that handles `OSError`s. And in the handle can be code or a call to an handler with the same paramaters `myHandler` accept.
msg349228 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-08-08 09:30
I don't see the point of shifting the burden to the caller.  That doesn't make their code smaller, clearer, faster, easier to write, or easier to get right.   Also, deprecations almost always cause pain so we try to avoid them unless the feature is actually detrimental.
msg349229 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-08-08 09:35
Passing ignore_errors=True is not the same as catching and silencing OSError outside of the function. In the former case you continue removing other files in the directory even if you can't remove some of them. In the latter case you stop after the first failure.

onerror gives you even more flexibility.
msg349231 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2019-08-08 11:01
There’s too much code out there relying on both args (especially ignore_errors in unit tests) that would break for no real benefit.
History
Date User Action Args
2022-04-11 14:59:18adminsetgithub: 81972
2019-08-08 11:01:24giampaolo.rodolasetmessages: + msg349231
2019-08-08 09:35:36serhiy.storchakasetstatus: open -> closed
resolution: rejected
messages: + msg349229

stage: resolved
2019-08-08 09:30:16rhettingersetnosy: + rhettinger
messages: + msg349228
2019-08-08 08:45:21xtreaksetnosy: + giampaolo.rodola, tarek, serhiy.storchaka
2019-08-08 08:35:36Marco Sullasettitle: Propose to deprecate ignore_errors, -> Propose to deprecate `ignore_errors` and `onerror` parameters of `shutil.rmtree()`
versions: + Python 3.9
messages: + msg349223

components: + Library (Lib)
type: enhancement
2019-08-08 08:20:45Marco Sullacreate