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.

Author andrei.avk
Recipients andrei.avk, kj, mehwhatever0, serhiy.storchaka
Date 2021-11-30.14:36:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1638282962.36.0.530792305976.issue43153@roundup.psfhosted.org>
In-reply-to
Content
My last comment was wrong, the issue I linked is unrelated.

I think the actual issue here is the code here:
https://github.com/python/cpython/blob/4b97d974ecca9cce532be55410fe851eb9fdcf21/Lib/tempfile.py#L826

If `path` is a file that causes a permission error, `rmtree` is called and causes a NotADirectory error.

This can be confusing when debugging and can lead to a bug if user's code tries to catch a PermissionError it expects but instead gets NotADirectory error.

A solution is probably to check if path is a file and error is PermissionError and if ignore_errors=False, re-raise it instead of calling rmtree(). If ignore_errors=True, return instead of calling rmtree().

I don't have windows so can't test the OP code with this approach.

Serhiy: adding you since you wrote `def onerror()` in tempfile module, do you think that is the cause of the issue and the right solution for it?
History
Date User Action Args
2021-11-30 14:36:02andrei.avksetrecipients: + andrei.avk, serhiy.storchaka, kj, mehwhatever0
2021-11-30 14:36:02andrei.avksetmessageid: <1638282962.36.0.530792305976.issue43153@roundup.psfhosted.org>
2021-11-30 14:36:02andrei.avklinkissue43153 messages
2021-11-30 14:36:02andrei.avkcreate