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/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py
index 8bdebe6..034828b 100755
--- a/Mac/BuildScript/build-installer.py
+++ b/Mac/BuildScript/build-installer.py
@@ -335,7 +335,7 @@
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)
diff --git a/Mac/Demo/applescript/makedisk.py b/Mac/Demo/applescript/makedisk.py
index 91210ee..013331c 100644
--- a/Mac/Demo/applescript/makedisk.py
+++ b/Mac/Demo/applescript/makedisk.py
@@ -7,7 +7,7 @@
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
diff --git a/Mac/Demo/imgbrowse/imgbrowse.py b/Mac/Demo/imgbrowse/imgbrowse.py
index 28dffd3..57cddd3 100644
--- a/Mac/Demo/imgbrowse/imgbrowse.py
+++ b/Mac/Demo/imgbrowse/imgbrowse.py
@@ -52,7 +52,7 @@
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
diff --git a/Mac/Demo/mlte/mlted.py b/Mac/Demo/mlte/mlted.py
index 323ea62..f9ccd21 100644
--- a/Mac/Demo/mlte/mlted.py
+++ b/Mac/Demo/mlte/mlted.py
@@ -275,7 +275,7 @@
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:
diff --git a/Mac/Demo/resources/copyres.py b/Mac/Demo/resources/copyres.py
index cb1fa8e..da55b06 100644
--- a/Mac/Demo/resources/copyres.py
+++ b/Mac/Demo/resources/copyres.py
@@ -39,7 +39,7 @@
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"
diff --git a/Mac/Demo/textedit/ped.py b/Mac/Demo/textedit/ped.py
index 3e91b32..8cd4713 100644
--- a/Mac/Demo/textedit/ped.py
+++ b/Mac/Demo/textedit/ped.py
@@ -273,7 +273,7 @@
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:
diff --git a/Mac/scripts/BuildApplet.py b/Mac/scripts/BuildApplet.py
index e71ebc1..9ddcd0b 100644
--- a/Mac/scripts/BuildApplet.py
+++ b/Mac/scripts/BuildApplet.py
@@ -31,7 +31,7 @@
def main():
try:
buildapplet()
- except buildtools.BuildError, detail:
+ except buildtools.BuildError as detail:
EasyDialogs.Message(detail)
diff --git a/Mac/scripts/buildpkg.py b/Mac/scripts/buildpkg.py
index e6dc474..e50c405 100644
--- a/Mac/scripts/buildpkg.py
+++ b/Mac/scripts/buildpkg.py
@@ -451,7 +451,7 @@
try:
opts, args = getopt.getopt(sys.argv[1:], shortOpts, longOpts)
- except getopt.GetoptError, details:
+ except getopt.GetoptError as details:
print details
printUsage()
return