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:
parent
90115a2cf7
commit
14a343a9af
|
@ -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)):
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
The ``onerror`` callback from ``shutil.rmtree`` now receives correct function when ``os.open`` fails.
|
Loading…
Reference in New Issue