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/Tools/unicode/comparecodecs.py b/Tools/unicode/comparecodecs.py
index cd417a4..a293283 100644
--- a/Tools/unicode/comparecodecs.py
+++ b/Tools/unicode/comparecodecs.py
@@ -18,11 +18,11 @@
u = unichr(i)
try:
c1 = u.encode(encoding1)
- except UnicodeError, reason:
+ except UnicodeError as reason:
c1 = '<undefined>'
try:
c2 = u.encode(encoding2)
- except UnicodeError, reason:
+ except UnicodeError as reason:
c2 = '<undefined>'
if c1 != c2:
print ' * encoding mismatch for 0x%04X: %-14r != %r' % \
diff --git a/Tools/unicode/gencodec.py b/Tools/unicode/gencodec.py
index dabcd72..47d81eb 100644
--- a/Tools/unicode/gencodec.py
+++ b/Tools/unicode/gencodec.py
@@ -130,7 +130,7 @@
try:
return '(' + ', '.join(['0x%0*X' % (precision, item)
for item in t]) + ')'
- except TypeError, why:
+ except TypeError as why:
print '* failed to convert %r: %s' % (t, why)
raise
@@ -393,7 +393,7 @@
else:
pymap(mappathname, map, dirprefix + codefile,name,comments)
marshalmap(mappathname, map, dirprefix + marshalfile)
- except ValueError, why:
+ except ValueError as why:
print '* conversion failed: %s' % why
raise
@@ -414,7 +414,7 @@
print '* map is empty; skipping'
else:
pymap(mapname, map, dirprefix + codefile,name,comments)
- except ValueError, why:
+ except ValueError as why:
print '* conversion failed: %s' % why
if __name__ == '__main__':
diff --git a/Tools/unicode/listcodecs.py b/Tools/unicode/listcodecs.py
index 19d21e1..c196ced 100644
--- a/Tools/unicode/listcodecs.py
+++ b/Tools/unicode/listcodecs.py
@@ -22,7 +22,7 @@
except LookupError:
# Codec not found
continue
- except Exception, reason:
+ except Exception as reason:
# Probably an error from importing the codec; still it's
# a valid code name
if _debug: