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 e59b2deffd)

Co-authored-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Miss Islington (bot) 2020-11-10 08:29:35 -08:00 committed by GitHub
parent 90115a2cf7
commit 14a343a9af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -711,7 +711,7 @@ def rmtree(path, ignore_errors=False, onerror=None):
try:
fd = os.open(path, os.O_RDONLY)
except Exception:
onerror(os.lstat, path, sys.exc_info())
onerror(os.open, path, sys.exc_info())
return
try:
if os.path.samestat(orig_st, os.fstat(fd)):

View File

@ -0,0 +1 @@
The ``onerror`` callback from ``shutil.rmtree`` now receives correct function when ``os.open`` fails.