Skip to content

Commit b940e11

Browse files
committed
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
1 parent 893523e commit b940e11

File tree

295 files changed

+817
-743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

295 files changed

+817
-743
lines changed

Demo/cgi/wiki.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,5 @@ def store(self):
119119
f.write('\n')
120120
f.close()
121121
return ""
122-
except IOError, err:
122+
except IOError as err:
123123
return "IOError: %s" % str(err)

Demo/comparisons/regextest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def main():
2828
for file in sys.argv[1:]:
2929
try:
3030
fp = open(file, 'r')
31-
except IOError, msg:
31+
except IOError as msg:
3232
print "%s: %s" % (file, msg)
3333
continue
3434
lineno = 0

Demo/comparisons/systemtest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def main():
4141
def reportboguslinks(prefix):
4242
try:
4343
names = os.listdir('.')
44-
except os.error, msg:
44+
except os.error as msg:
4545
print "%s%s: can't list: %s" % (prefix, '.', msg)
4646
return
4747
names.sort()
@@ -62,7 +62,7 @@ def reportboguslinks(prefix):
6262
elif S_ISDIR(mode):
6363
try:
6464
os.chdir(name)
65-
except os.error, msg:
65+
except os.error as msg:
6666
print "%s%s: can't chdir: %s" % \
6767
(prefix, name, msg)
6868
continue

Demo/parser/test_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def testChunk(t, fileName):
1717
# against a large source file like Tkinter.py.
1818
ast = None
1919
new = parser.tuple2ast(tup)
20-
except parser.ParserError, err:
20+
except parser.ParserError as err:
2121
print
2222
print 'parser module raised exception on input file', fileName + ':'
2323
traceback.print_exc()

Demo/parser/unparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def testdir(a):
492492
print 'Testing %s' % fullname
493493
try:
494494
roundtrip(fullname, output)
495-
except Exception, e:
495+
except Exception as e:
496496
print ' Failed to compile, exception is %s' % repr(e)
497497
elif os.path.isdir(fullname):
498498
testdir(fullname)

Demo/pdist/FSProxy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def visible(self, name):
8787
fs = macfs.FSSpec(name)
8888
c, t = fs.GetCreatorType()
8989
if t != 'TEXT': return 0
90-
except macfs.error, msg:
90+
except macfs.error as msg:
9191
print "***", name, msg
9292
return 0
9393
else:

Demo/pdist/cmdfw.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def run(self, args = None):
4242
if args is None: args = sys.argv[1:]
4343
try:
4444
opts, args = getopt.getopt(args, self.GlobalFlags)
45-
except getopt.error, msg:
45+
except getopt.error as msg:
4646
return self.usage(msg)
4747
self.options(opts)
4848
if not args:
@@ -62,7 +62,7 @@ def run(self, args = None):
6262
flags = ''
6363
try:
6464
opts, args = getopt.getopt(args[1:], flags)
65-
except getopt.error, msg:
65+
except getopt.error as msg:
6666
return self.usage(
6767
"subcommand %s: " % cmd + str(msg))
6868
self.ready()

Demo/pdist/cmptree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def compare(local, remote, mode):
135135
def sendfile(local, remote, name):
136136
try:
137137
remote.create(name)
138-
except (IOError, os.error), msg:
138+
except (IOError, os.error) as msg:
139139
print "cannot create:", msg
140140
return
141141

@@ -171,7 +171,7 @@ def recvfile(local, remote, name):
171171
def recvfile_real(local, remote, name):
172172
try:
173173
local.create(name)
174-
except (IOError, os.error), msg:
174+
except (IOError, os.error) as msg:
175175
print "cannot create:", msg
176176
return
177177

Demo/pdist/cvslock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def setlockdir(self):
129129
self.lockdir = self.cvslck
130130
os.mkdir(self.cvslck, 0777)
131131
return
132-
except os.error, msg:
132+
except os.error as msg:
133133
self.lockdir = None
134134
if msg[0] == EEXIST:
135135
try:
@@ -234,7 +234,7 @@ def MultipleWriteLock(repositories, delay = DELAY):
234234
for r in repositories:
235235
try:
236236
locks.append(WriteLock(r, 0))
237-
except Locked, instance:
237+
except Locked as instance:
238238
del locks
239239
break
240240
else:

Demo/pdist/rrcs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def main():
2222
raise getopt.error, "unknown command"
2323
coptset, func = commands[cmd]
2424
copts, files = getopt.getopt(rest, coptset)
25-
except getopt.error, msg:
25+
except getopt.error as msg:
2626
print msg
2727
print "usage: rrcs [options] command [options] [file] ..."
2828
print "where command can be:"
@@ -41,7 +41,7 @@ def main():
4141
for fn in files:
4242
try:
4343
func(x, copts, fn)
44-
except (IOError, os.error), msg:
44+
except (IOError, os.error) as msg:
4545
print "%s: %s" % (fn, msg)
4646

4747
def checkin(x, copts, fn):

0 commit comments

Comments
 (0)