The onexc argument was added two weeks ago to replace onerror: d51a6dc
Though it improves the third argument (replacing a 3-tuple with the exception object), I think we should also consider two further improvements while we're in the business of replacing onerror, as the opportunity may not come again for a long time:
- The first argument,
function, provides an unreasonably deep insight into the internals of rmtree(). The implementation already bends the truth, for example supplying os.path.islink when a junction check fails. Error reporting can already be achieved by printing or re-raising the exception. It's not used in the standard library (e.g. by tempfile). What legitimate use cases are there? I propose we remove it!
- The second argument,
path, is already be available via exc.filename. This is noted in os.walk()'s documentation of its onerror argument. Also propose we remove it.
If we make onexc accept a single argument, it would align with the onerror argument to os.walk() and os.fwalk(), and provide more relevant (/less redundant) information.
The
onexcargument was added two weeks ago to replaceonerror: d51a6dcThough it improves the third argument (replacing a 3-tuple with the exception object), I think we should also consider two further improvements while we're in the business of replacing
onerror, as the opportunity may not come again for a long time:function, provides an unreasonably deep insight into the internals ofrmtree(). The implementation already bends the truth, for example supplyingos.path.islinkwhen a junction check fails. Error reporting can already be achieved by printing or re-raising the exception. It's not used in the standard library (e.g. bytempfile). What legitimate use cases are there? I propose we remove it!path, is already be available viaexc.filename. This is noted inos.walk()'s documentation of itsonerrorargument. Also propose we remove it.If we make
onexcaccept a single argument, it would align with theonerrorargument toos.walk()andos.fwalk(), and provide more relevant (/less redundant) information.