Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 66d16ba

Browse files
committed
- squashed bare except in rmtree()
- improved readability of rmtree; removed silly apply()
1 parent 502b9e1 commit 66d16ba

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

Lib/shutil.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,17 @@ def rmtree(path, ignore_errors=0, onerror=None):
127127
"""
128128
cmdtuples = []
129129
_build_cmdtuple(path, cmdtuples)
130-
for cmd in cmdtuples:
130+
for func, arg in cmdtuples:
131131
try:
132-
apply(cmd[0], (cmd[1],))
133-
except:
132+
func(arg)
133+
except OSError:
134134
exc = sys.exc_info()
135135
if ignore_errors:
136136
pass
137137
elif onerror is not None:
138-
onerror(cmd[0], cmd[1], exc)
138+
onerror(func, arg, exc)
139139
else:
140-
raise exc[0], (exc[1][0], exc[1][1] + ' removing '+cmd[1])
140+
raise exc[0], (exc[1][0], exc[1][1] + ' removing '+arg)
141141

142142
# Helper for rmtree()
143143
def _build_cmdtuple(path, cmdtuples):

0 commit comments

Comments
 (0)