Merge pull request #1725 from fsouza/fix-rmtree

util: also run chmod on EPERM
This commit is contained in:
Anthony Sottile 2020-12-06 10:27:15 -08:00 committed by GitHub
commit cf604f6b93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -255,7 +255,7 @@ def rmtree(path: str) -> None:
excvalue = exc[1]
if (
func in (os.rmdir, os.remove, os.unlink) and
excvalue.errno == errno.EACCES
excvalue.errno in {errno.EACCES, errno.EPERM}
):
for p in (path, os.path.dirname(path)):
os.chmod(p, os.stat(p).st_mode | stat.S_IWUSR)