Skip to content

Commit 14a343a

Browse files
bpo-42014: shutil.rmtree: call onerror with correct function (GH-22585)
The onerror is supposed to be called with failed function, but in this case lstat is wrongly used instead of open. Not sure if this needs bug or not... Automerge-Triggered-By: GH:hynek (cherry picked from commit e59b2de) Co-authored-by: Michal Čihař <michal@cihar.com>
1 parent 90115a2 commit 14a343a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Lib/shutil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ def onerror(*args):
711711
try:
712712
fd = os.open(path, os.O_RDONLY)
713713
except Exception:
714-
onerror(os.lstat, path, sys.exc_info())
714+
onerror(os.open, path, sys.exc_info())
715715
return
716716
try:
717717
if os.path.samestat(orig_st, os.fstat(fd)):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The ``onerror`` callback from ``shutil.rmtree`` now receives correct function when ``os.open`` fails.

0 commit comments

Comments
 (0)