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
This commit is contained in:
Michal Čihař 2020-11-10 17:06:02 +01:00 committed by GitHub
parent 3eb2846225
commit e59b2deffd
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: try:
fd = os.open(path, os.O_RDONLY) fd = os.open(path, os.O_RDONLY)
except Exception: except Exception:
onerror(os.lstat, path, sys.exc_info()) onerror(os.open, path, sys.exc_info())
return return
try: try:
if os.path.samestat(orig_st, os.fstat(fd)): 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.