SF patch 1631942 by Collin Winter:
(a) "except E, V" -> "except E as V"
(b) V is now limited to a simple name (local variable)
(c) V is now deleted at the end of the except block
diff --git a/Lib/shutil.py b/Lib/shutil.py
index c3ff687..7da5cac 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -121,18 +121,18 @@
else:
copy2(srcname, dstname)
# XXX What about devices, sockets etc.?
- except (IOError, os.error), why:
+ except (IOError, os.error) as why:
errors.append((srcname, dstname, str(why)))
# catch the Error from the recursive copytree so that we can
# continue with other files
- except Error, err:
+ except Error as err:
errors.extend(err.args[0])
try:
copystat(src, dst)
except WindowsError:
# can't copy file access times on Windows
pass
- except OSError, why:
+ except OSError as why:
errors.extend((src, dst, str(why)))
if errors:
raise Error, errors
@@ -157,7 +157,7 @@
names = []
try:
names = os.listdir(path)
- except os.error, err:
+ except os.error as err:
onerror(os.listdir, path, sys.exc_info())
for name in names:
fullname = os.path.join(path, name)
@@ -170,7 +170,7 @@
else:
try:
os.remove(fullname)
- except os.error, err:
+ except os.error as err:
onerror(os.remove, fullname, sys.exc_info())
try:
os.rmdir(path)