From: Victor Stinner Date: Mon, 21 Jul 2014 17:18:12 +0000 (+0200) Subject: Issue #19629: Fix support.rmtree(), use os.lstat() to check if the file is a X-Git-Tag: v3.4.2rc1~200 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67f8706521596adcc1a77209d3639e19cfaa65b2;p=python Issue #19629: Fix support.rmtree(), use os.lstat() to check if the file is a directory, not os.path.isdir() --- diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index c1a187d3bb..d321bb4d6b 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -316,7 +316,13 @@ if sys.platform.startswith("win"): 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: