- squashed bare except in rmtree()

- improved readability of rmtree; removed silly apply()
This commit is contained in:
Just van Rossum 2003-01-05 19:44:11 +00:00
parent 502b9e1fbb
commit 66d16baf71
1 changed files with 5 additions and 5 deletions

View File

@ -127,17 +127,17 @@ def rmtree(path, ignore_errors=0, onerror=None):
""" """
cmdtuples = [] cmdtuples = []
_build_cmdtuple(path, cmdtuples) _build_cmdtuple(path, cmdtuples)
for cmd in cmdtuples: for func, arg in cmdtuples:
try: try:
apply(cmd[0], (cmd[1],)) func(arg)
except: except OSError:
exc = sys.exc_info() exc = sys.exc_info()
if ignore_errors: if ignore_errors:
pass pass
elif onerror is not None: elif onerror is not None:
onerror(cmd[0], cmd[1], exc) onerror(func, arg, exc)
else: else:
raise exc[0], (exc[1][0], exc[1][1] + ' removing '+cmd[1]) raise exc[0], (exc[1][0], exc[1][1] + ' removing '+arg)
# Helper for rmtree() # Helper for rmtree()
def _build_cmdtuple(path, cmdtuples): def _build_cmdtuple(path, cmdtuples):