]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-42014: shutil.rmtree: call onerror with correct function (GH-22585)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 10 Nov 2020 16:27:02 +0000 (08:27 -0800)
committerGitHub <noreply@github.com>
Tue, 10 Nov 2020 16:27:02 +0000 (08:27 -0800)
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 e59b2deffde61e5641cabd65034fa11b4db898ba)

Co-authored-by: Michal Čihař <michal@cihar.com>
Lib/shutil.py
Misc/NEWS.d/next/Library/2020-11-10-15-40-56.bpo-42014.ShM37l.rst [new file with mode: 0644]

index 9d151493e766758f1a8576557c5c5203b9aa1acd..6986bce8aaee2d30a7a4a8b1b397f4ac15a8738e 100644 (file)
@@ -711,7 +711,7 @@ def rmtree(path, ignore_errors=False, onerror=None):
         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 (file)
index 0000000..d3e1abc
--- /dev/null
@@ -0,0 +1 @@
+The ``onerror`` callback from ``shutil.rmtree`` now receives correct function when ``os.open`` fails.
\ No newline at end of file