mirror of https://github.com/python/cpython
Merge Python 3.4
* Issue #19811, #22022: test_pathlib uses support.rmtree() instead of shutil.rmtree() to remove the temporary directory. * Issue #19629: Fix support.rmtree(), use os.lstat() to check if the file is a directory, not os.path.isdir()
This commit is contained in:
commit
963b4bab52
|
@ -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:
|
||||
|
|
|
@ -1214,7 +1214,7 @@ class _BasePathTest(object):
|
|||
|
||||
def setUp(self):
|
||||
os.mkdir(BASE)
|
||||
self.addCleanup(shutil.rmtree, BASE)
|
||||
self.addCleanup(support.rmtree, BASE)
|
||||
os.mkdir(join('dirA'))
|
||||
os.mkdir(join('dirB'))
|
||||
os.mkdir(join('dirC'))
|
||||
|
@ -1419,7 +1419,7 @@ class _BasePathTest(object):
|
|||
self._check_resolve_relative(p, P(BASE, 'dirB', 'fileB'))
|
||||
# Now create absolute symlinks
|
||||
d = tempfile.mkdtemp(suffix='-dirD')
|
||||
self.addCleanup(shutil.rmtree, d)
|
||||
self.addCleanup(support.rmtree, d)
|
||||
os.symlink(os.path.join(d), join('dirA', 'linkX'))
|
||||
os.symlink(join('dirB'), os.path.join(d, 'linkY'))
|
||||
p = P(BASE, 'dirA', 'linkX', 'linkY', 'fileB')
|
||||
|
|
Loading…
Reference in New Issue