From 7424b4543315efaa35b6337cdcc27e572193eabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 7 Oct 2020 12:11:25 +0200 Subject: [PATCH 1/2] shutil.rmtree: call onerror with correct function The onerror is supposed to be called with failed function, but in this case lstat is wrongly used instead of open. --- Lib/shutil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/shutil.py b/Lib/shutil.py index a4ce2c0290bc93..6f74c8a51df1a4 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -708,7 +708,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)): From d4076cae32958403d4a48636d86dfa83bad72117 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2020 15:40:57 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NEWS.d/next/Library/2020-11-10-15-40-56.bpo-42014.ShM37l.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2020-11-10-15-40-56.bpo-42014.ShM37l.rst 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 00000000000000..d3e1abcd84c1e8 --- /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