[Python-checkins] bpo-42014: shutil.rmtree: call onerror with correct function (GH-22585)
miss-islington
webhook-mailer at python.org
Tue Nov 10 11:06:11 EST 2020
https://github.com/python/cpython/commit/e59b2deffde61e5641cabd65034fa11b4db898ba
commit: e59b2deffde61e5641cabd65034fa11b4db898ba
branch: master
author: Michal Čihař <michal at cihar.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2020-11-10T08:06:02-08:00
summary:
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
files:
A Misc/NEWS.d/next/Library/2020-11-10-15-40-56.bpo-42014.ShM37l.rst
M Lib/shutil.py
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 223e9a8a70506..f0e833dc979b7 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -711,7 +711,7 @@ def onerror(*args):
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)):
diff --git a/Misc/NEWS.d/next/Library/2020-11-10-15-40-56.bpo-42014.ShM37l.rst b/Misc/NEWS.d/next/Library/2020-11-10-15-40-56.bpo-42014.ShM37l.rst
new file mode 100644
index 0000000000000..d3e1abcd84c1e
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-11-10-15-40-56.bpo-42014.ShM37l.rst
@@ -0,0 +1 @@
+The ``onerror`` callback from ``shutil.rmtree`` now receives correct function when ``os.open`` fails.
\ No newline at end of file
More information about the Python-checkins
mailing list