mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
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
This commit is contained in:
parent
893523e80a
commit
b940e113bf
295 changed files with 817 additions and 743 deletions
|
|
@ -335,7 +335,7 @@ def parseOptions(args=None):
|
|||
try:
|
||||
options, args = getopt.getopt(args, '?hb',
|
||||
[ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir='])
|
||||
except getopt.error, msg:
|
||||
except getopt.error as msg:
|
||||
print msg
|
||||
sys.exit(1)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ talker.activate()
|
|||
filespec = macfs.FSSpec('my disk image.img')
|
||||
try:
|
||||
objref = talker.create('my disk image', saving_as=filespec, leave_image_mounted=1)
|
||||
except Disk_Copy.Error, arg:
|
||||
except Disk_Copy.Error as arg:
|
||||
print "ERROR: my disk image:", arg
|
||||
else:
|
||||
print 'objref=', objref
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class imgbrowse(FrameWork.Application):
|
|||
bar = EasyDialogs.ProgressBar('Reading and converting...')
|
||||
try:
|
||||
rdr = img.reader(imgformat.macrgb16, pathname)
|
||||
except img.error, arg:
|
||||
except img.error as arg:
|
||||
EasyDialogs.Message(repr(arg))
|
||||
return
|
||||
w, h = rdr.width, rdr.height
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ class Mlted(Application):
|
|||
fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line
|
||||
data = fp.read()
|
||||
fp.close()
|
||||
except IOError, arg:
|
||||
except IOError as arg:
|
||||
EasyDialogs.Message("IOERROR: %r" % (arg,))
|
||||
return
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ def copyres(src, dst):
|
|||
UseResFile(output)
|
||||
try:
|
||||
res2 = Get1Resource(type, id)
|
||||
except (RuntimeError, Res.Error), msg:
|
||||
except (RuntimeError, Res.Error) as msg:
|
||||
res2 = None
|
||||
if res2:
|
||||
print "Duplicate type+id, not copied"
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ class Ped(Application):
|
|||
fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line
|
||||
data = fp.read()
|
||||
fp.close()
|
||||
except IOError, arg:
|
||||
except IOError as arg:
|
||||
EasyDialogs.Message("IOERROR: %r" % (arg,))
|
||||
return
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ if not sys.executable.startswith(sys.exec_prefix):
|
|||
def main():
|
||||
try:
|
||||
buildapplet()
|
||||
except buildtools.BuildError, detail:
|
||||
except buildtools.BuildError as detail:
|
||||
EasyDialogs.Message(detail)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ def main():
|
|||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], shortOpts, longOpts)
|
||||
except getopt.GetoptError, details:
|
||||
except getopt.GetoptError as details:
|
||||
print details
|
||||
printUsage()
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue