Skip to content

Commit b8e009e

Browse files
committed
In rmtree, have onerror catch only PermissionError
The onerror function is still called on, and tries to resolve, any exception. But now, when it re-calls the file deletion function passed as func, the only exception it catches to conditionally convert to SkipTest is PermissionError (or derived exceptions). The old behavior of catching Exception was overly broad, and inconsistent with the hard-coded prefix of "FIXME: fails with: PermissionError" used to build the SkipTest exception messages. This commit also changes the message to use an f-string (which was one of the styles in the equivalent but differently coded duplicate logic eliminated in 5039df3, and seems clearer in this case). That change is a pure refactoring, not affecting generated messages.
1 parent 2a32e25 commit b8e009e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

git/util.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ def onerror(func: Callable, path: PathLike, exc_info: str) -> None:
188188

189189
try:
190190
func(path) # Will scream if still not possible to delete.
191-
except Exception as ex:
191+
except PermissionError as ex:
192192
if HIDE_WINDOWS_KNOWN_ERRORS:
193193
from unittest import SkipTest
194194

195-
raise SkipTest("FIXME: fails with: PermissionError\n {}".format(ex)) from ex
195+
raise SkipTest(f"FIXME: fails with: PermissionError\n {ex}") from ex
196196
raise
197197

198198
return shutil.rmtree(path, False, onerror)

0 commit comments

Comments
 (0)