[Python-checkins] cpython (3.4): Issue #19629: Fix support.rmtree(), use os.lstat() to check if the file is a
victor.stinner
python-checkins at python.org
Mon Jul 21 19:20:31 CEST 2014
http://hg.python.org/cpython/rev/28bb1aa9ca3d
changeset: 91747:28bb1aa9ca3d
branch: 3.4
parent: 91743:cb8fc24e209f
user: Victor Stinner <victor.stinner at gmail.com>
date: Mon Jul 21 19:18:12 2014 +0200
summary:
Issue #19629: Fix support.rmtree(), use os.lstat() to check if the file is a
directory, not os.path.isdir()
files:
Lib/test/support/__init__.py | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -316,7 +316,13 @@
def _rmtree_inner(path):
for name in os.listdir(path):
fullname = os.path.join(path, name)
- if os.path.isdir(fullname):
+ try:
+ mode = os.lstat(fullname).st_mode
+ except OSError as exc:
+ print("support.rmtree(): os.lstat(%r) failed with %s" % (fullname, exc),
+ file=sys.__stderr__)
+ mode = 0
+ if stat.S_ISDIR(mode):
_waitfor(_rmtree_inner, fullname, waitall=True)
os.rmdir(fullname)
else:
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list