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/scripts/fixcid.py b/Tools/scripts/fixcid.py
index 433a425..29e0e10 100755
--- a/Tools/scripts/fixcid.py
+++ b/Tools/scripts/fixcid.py
@@ -62,7 +62,7 @@
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], 'crs:')
- except getopt.error, msg:
+ except getopt.error as msg:
err('Options error: ' + str(msg) + '\n')
usage()
sys.exit(2)
@@ -97,7 +97,7 @@
bad = 0
try:
names = os.listdir(dirname)
- except os.error, msg:
+ except os.error as msg:
err(dirname + ': cannot list directory: ' + str(msg) + '\n')
return 1
names.sort()
@@ -124,7 +124,7 @@
# File replacement mode
try:
f = open(filename, 'r')
- except IOError, msg:
+ except IOError as msg:
err(filename + ': cannot open: ' + str(msg) + '\n')
return 1
head, tail = os.path.split(filename)
@@ -148,7 +148,7 @@
if g is None:
try:
g = open(tempname, 'w')
- except IOError, msg:
+ except IOError as msg:
f.close()
err(tempname+': cannot create: '+
str(msg)+'\n')
@@ -175,17 +175,17 @@
try:
statbuf = os.stat(filename)
os.chmod(tempname, statbuf[ST_MODE] & 07777)
- except os.error, msg:
+ except os.error as msg:
err(tempname + ': warning: chmod failed (' + str(msg) + ')\n')
# Then make a backup of the original file as filename~
try:
os.rename(filename, filename + '~')
- except os.error, msg:
+ except os.error as msg:
err(filename + ': warning: backup failed (' + str(msg) + ')\n')
# Now move the temp file to the original file
try:
os.rename(tempname, filename)
- except os.error, msg:
+ except os.error as msg:
err(filename + ': rename failed (' + str(msg) + ')\n')
return 1
# Return succes
@@ -276,7 +276,7 @@
def addsubst(substfile):
try:
fp = open(substfile, 'r')
- except IOError, msg:
+ except IOError as msg:
err(substfile + ': cannot read substfile: ' + str(msg) + '\n')
sys.exit(1)
lineno = 0