Message407376
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? |
|
Date |
User |
Action |
Args |
2021-11-30 14:36:02 | andrei.avk | set | recipients:
+ andrei.avk, serhiy.storchaka, kj, mehwhatever0 |
2021-11-30 14:36:02 | andrei.avk | set | messageid: <1638282962.36.0.530792305976.issue43153@roundup.psfhosted.org> |
2021-11-30 14:36:02 | andrei.avk | link | issue43153 messages |
2021-11-30 14:36:02 | andrei.avk | create | |
|