Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb0d957

Browse files
committed
util: also run chmod on EPERM
Writing a test for this one is tricky, because I was seeing the issue only when the directory being removed is a docker volume, so instead of getting EACCES we get EPERM. This is easy to reproduce though. The existing test fails when the directory being used for the files is a docker volume: ``` % docker run \ -v $(mktemp -d):/tmp \ -v ${PWD}:/src \ -w /src \ python:3 \ bash -c 'pip install -e . && pip install -r requirements-dev.txt && python -m pytest tests/util_test.py' ```
1 parent 92ce2dc commit bb0d957

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

pre_commit/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def handle_remove_readonly(
255255
excvalue = exc[1]
256256
if (
257257
func in (os.rmdir, os.remove, os.unlink) and
258-
excvalue.errno == errno.EACCES
258+
excvalue.errno in (errno.EACCES, errno.EPERM)
259259
):
260260
for p in (path, os.path.dirname(path)):
261261
os.chmod(p, os.stat(p).st_mode | stat.S_IWUSR)

0 commit comments

Comments
 (0)