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:
parent
3eb2846225
commit
e59b2deffd
|
@ -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