- squashed bare except in rmtree()
authorJust van Rossum <just@letterror.com>
Sun, 5 Jan 2003 19:44:11 +0000 (19:44 +0000)
committerJust van Rossum <just@letterror.com>
Sun, 5 Jan 2003 19:44:11 +0000 (19:44 +0000)
- improved readability of rmtree; removed silly apply()

Lib/shutil.py

index 6aa2e3d669e44f78939bf264ed8e78a20ba12fc4..ad5c99d38f07b75e8f74db6d20e1661df9590e01 100644 (file)
@@ -127,17 +127,17 @@ def rmtree(path, ignore_errors=0, onerror=None):
     """
     cmdtuples = []
     _build_cmdtuple(path, cmdtuples)
-    for cmd in cmdtuples:
+    for func, arg in cmdtuples:
         try:
-            apply(cmd[0], (cmd[1],))
-        except:
+            func(arg)
+        except OSError:
             exc = sys.exc_info()
             if ignore_errors:
                 pass
             elif onerror is not None:
-                onerror(cmd[0], cmd[1], exc)
+                onerror(func, arg, exc)
             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()
 def _build_cmdtuple(path, cmdtuples):