diff options
author | Guido van Rossum <guido@python.org> | 2007-01-10 16:19:56 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-01-10 16:19:56 (GMT) |
commit | b940e113bf90ff71b0ef57414ea2beea9d2a4bc0 (patch) | |
tree | 0b9ea19eba1e665dac95126c3140ac2bc36326ad /Lib/plat-mac | |
parent | 893523e80a2003d4a630aafb84ba016e0070cbbd (diff) | |
download | cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.zip cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.tar.gz cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.tar.bz2 |
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
Diffstat (limited to 'Lib/plat-mac')
-rw-r--r-- | Lib/plat-mac/EasyDialogs.py | 6 | ||||
-rw-r--r-- | Lib/plat-mac/MiniAEFrame.py | 2 | ||||
-rw-r--r-- | Lib/plat-mac/aetools.py | 4 | ||||
-rw-r--r-- | Lib/plat-mac/applesingle.py | 4 | ||||
-rw-r--r-- | Lib/plat-mac/argvemulator.py | 4 | ||||
-rw-r--r-- | Lib/plat-mac/buildtools.py | 2 | ||||
-rwxr-xr-x | Lib/plat-mac/bundlebuilder.py | 2 | ||||
-rw-r--r-- | Lib/plat-mac/gensuitemodule.py | 6 | ||||
-rw-r--r-- | Lib/plat-mac/macresource.py | 8 | ||||
-rw-r--r-- | Lib/plat-mac/pimp.py | 10 | ||||
-rw-r--r-- | Lib/plat-mac/terminalcommand.py | 2 |
11 files changed, 25 insertions, 25 deletions
diff --git a/Lib/plat-mac/EasyDialogs.py b/Lib/plat-mac/EasyDialogs.py index 1bd46a8..340e3ed 100644 --- a/Lib/plat-mac/EasyDialogs.py +++ b/Lib/plat-mac/EasyDialogs.py @@ -651,7 +651,7 @@ def AskFileForOpen( try: rr = Nav.NavChooseFile(args) good = 1 - except Nav.error, arg: + except Nav.error as arg: if arg[0] != -128: # userCancelledErr raise Nav.error, arg return None @@ -704,7 +704,7 @@ def AskFileForSave( try: rr = Nav.NavPutFile(args) good = 1 - except Nav.error, arg: + except Nav.error as arg: if arg[0] != -128: # userCancelledErr raise Nav.error, arg return None @@ -764,7 +764,7 @@ def AskFolder( try: rr = Nav.NavChooseFolder(args) good = 1 - except Nav.error, arg: + except Nav.error as arg: if arg[0] != -128: # userCancelledErr raise Nav.error, arg return None diff --git a/Lib/plat-mac/MiniAEFrame.py b/Lib/plat-mac/MiniAEFrame.py index 569cd7b..1d990af 100644 --- a/Lib/plat-mac/MiniAEFrame.py +++ b/Lib/plat-mac/MiniAEFrame.py @@ -70,7 +70,7 @@ class MiniApplication: msg = "High Level Event: %r %r" % (code(message), code(h | (v<<16))) try: AE.AEProcessAppleEvent(event) - except AE.Error, err: + except AE.Error as err: print 'AE error: ', err print 'in', msg traceback.print_exc() diff --git a/Lib/plat-mac/aetools.py b/Lib/plat-mac/aetools.py index 55288bf..7a52eb9a 100644 --- a/Lib/plat-mac/aetools.py +++ b/Lib/plat-mac/aetools.py @@ -57,7 +57,7 @@ aekeywords = [ def missed(ae): try: desc = ae.AEGetAttributeDesc('miss', 'keyw') - except AE.Error, msg: + except AE.Error as msg: return None return desc.data @@ -86,7 +86,7 @@ def unpackevent(ae, formodulename=""): for key in aekeywords: try: desc = ae.AEGetAttributeDesc(key, '****') - except (AE.Error, MacOS.Error), msg: + except (AE.Error, MacOS.Error) as msg: if msg[0] != -1701 and msg[0] != -1704: raise continue diff --git a/Lib/plat-mac/applesingle.py b/Lib/plat-mac/applesingle.py index 76bdb06..fdd163d 100644 --- a/Lib/plat-mac/applesingle.py +++ b/Lib/plat-mac/applesingle.py @@ -48,7 +48,7 @@ class AppleSingle(object): header = fileobj.read(AS_HEADER_LENGTH) try: magic, version, ig, nentry = struct.unpack(AS_HEADER_FORMAT, header) - except ValueError, arg: + except ValueError as arg: raise Error, "Unpack header error: %s" % (arg,) if verbose: print 'Magic: 0x%8.8x' % (magic,) @@ -65,7 +65,7 @@ class AppleSingle(object): for hdr in headers: try: restype, offset, length = struct.unpack(AS_ENTRY_FORMAT, hdr) - except ValueError, arg: + except ValueError as arg: raise Error, "Unpack entry error: %s" % (arg,) if verbose: print "Fork %d, offset %d, length %d" % (restype, offset, length) diff --git a/Lib/plat-mac/argvemulator.py b/Lib/plat-mac/argvemulator.py index 2d66f1c..fe9e8f8 100644 --- a/Lib/plat-mac/argvemulator.py +++ b/Lib/plat-mac/argvemulator.py @@ -52,7 +52,7 @@ class ArgvCollector: if what == kHighLevelEvent: try: AE.AEProcessAppleEvent(event) - except AE.Error, err: + except AE.Error as err: msg = "High Level Event: %r %r" % (hex(message), hex(h | (v<<16))) print 'AE error: ', err print 'in', msg @@ -77,7 +77,7 @@ class ArgvCollector: fsref = alias.FSResolveAlias(None)[0] pathname = fsref.as_pathname() sys.argv.append(pathname) - except Exception, e: + except Exception as e: print "argvemulator.py warning: can't unpack an open document event" import traceback traceback.print_exc() diff --git a/Lib/plat-mac/buildtools.py b/Lib/plat-mac/buildtools.py index 7c5d0f4..4a0efbf 100644 --- a/Lib/plat-mac/buildtools.py +++ b/Lib/plat-mac/buildtools.py @@ -78,7 +78,7 @@ def process(template, filename, destname, copy_codefragment=0, fp.close() try: code = compile(text + '\n', filename, "exec") - except SyntaxError, arg: + except SyntaxError as arg: raise BuildError, "Syntax error in script %s: %s" % (filename, arg) except EOFError: raise BuildError, "End-of-file in script %s" % (filename,) diff --git a/Lib/plat-mac/bundlebuilder.py b/Lib/plat-mac/bundlebuilder.py index d21fc3e..d58adf2 100755 --- a/Lib/plat-mac/bundlebuilder.py +++ b/Lib/plat-mac/bundlebuilder.py @@ -764,7 +764,7 @@ def makedirs(dir): directory. Don't moan if any path element already exists.""" try: os.makedirs(dir) - except OSError, why: + except OSError as why: if why.errno != errno.EEXIST: raise diff --git a/Lib/plat-mac/gensuitemodule.py b/Lib/plat-mac/gensuitemodule.py index 53c0a52..7d03d8f 100644 --- a/Lib/plat-mac/gensuitemodule.py +++ b/Lib/plat-mac/gensuitemodule.py @@ -114,7 +114,7 @@ def main_interactive(interact=0, basepkgname='StdSuites'): try: processfile(filename, edit_modnames=edit_modnames, basepkgname=basepkgname, verbose=sys.stderr) - except MacOS.Error, arg: + except MacOS.Error as arg: print "Error getting terminology:", arg print "Retry, manually parsing resources" processfile_fromresource(filename, edit_modnames=edit_modnames, @@ -190,7 +190,7 @@ def processfile(fullname, output=None, basepkgname=None, print >>verbose, "\nASKING FOR aete DICTIONARY IN", repr(fullname) try: aedescobj, launched = OSATerminology.GetAppTerminology(fullname) - except MacOS.Error, arg: + except MacOS.Error as arg: if arg[0] in (-1701, -192): # errAEDescNotFound, resNotFound if verbose: print >>verbose, "GetAppTerminology failed with errAEDescNotFound/resNotFound, trying manually" @@ -244,7 +244,7 @@ def getappterminology(fullname, verbose=None): talker = aetools.TalkTo(cr) try: talker._start() - except (MacOS.Error, aetools.Error), arg: + except (MacOS.Error, aetools.Error) as arg: if verbose: print >>verbose, 'Warning: start() failed, continuing anyway:', arg reply = talker.send("ascr", "gdte") diff --git a/Lib/plat-mac/macresource.py b/Lib/plat-mac/macresource.py index d5839a1..91dfffa 100644 --- a/Lib/plat-mac/macresource.py +++ b/Lib/plat-mac/macresource.py @@ -76,14 +76,14 @@ def open_pathname(pathname, verbose=0): AppleSingle file""" try: refno = Res.FSpOpenResFile(pathname, 1) - except Res.Error, arg: + except Res.Error as arg: if arg[0] in (-37, -39): # No resource fork. We may be on OSX, and this may be either # a data-fork based resource file or a AppleSingle file # from the CVS repository. try: refno = Res.FSOpenResourceFile(pathname, u'', 1) - except Res.Error, arg: + except Res.Error as arg: if arg[0] != -199: # -199 is "bad resource map" raise @@ -103,14 +103,14 @@ def resource_pathname(pathname, verbose=0): try: refno = Res.FSpOpenResFile(pathname, 1) Res.CloseResFile(refno) - except Res.Error, arg: + except Res.Error as arg: if arg[0] in (-37, -39): # No resource fork. We may be on OSX, and this may be either # a data-fork based resource file or a AppleSingle file # from the CVS repository. try: refno = Res.FSOpenResourceFile(pathname, u'', 1) - except Res.Error, arg: + except Res.Error as arg: if arg[0] != -199: # -199 is "bad resource map" raise diff --git a/Lib/plat-mac/pimp.py b/Lib/plat-mac/pimp.py index ff696b1..6927ad7 100644 --- a/Lib/plat-mac/pimp.py +++ b/Lib/plat-mac/pimp.py @@ -76,7 +76,7 @@ def getDefaultDatabase(experimental=False): url = DEFAULT_PIMPDATABASE_FMT % (PIMP_VERSION, status, pyvers, osname, rel, machine) try: urllib2.urlopen(url) - except urllib2.HTTPError, arg: + except urllib2.HTTPError as arg: pass else: break @@ -589,13 +589,13 @@ class PimpPackage: installTest = self._dict['Install-test'].strip() + '\n' try: exec(installTest, namespace) - except ImportError, arg: + except ImportError as arg: return "no", str(arg) - except _scriptExc_NotInstalled, arg: + except _scriptExc_NotInstalled as arg: return "no", str(arg) - except _scriptExc_OldInstalled, arg: + except _scriptExc_OldInstalled as arg: return "old", str(arg) - except _scriptExc_BadInstalled, arg: + except _scriptExc_BadInstalled as arg: return "bad", str(arg) except: sys.stderr.write("-------------------------------------\n") diff --git a/Lib/plat-mac/terminalcommand.py b/Lib/plat-mac/terminalcommand.py index 292f09c..a2f008c 100644 --- a/Lib/plat-mac/terminalcommand.py +++ b/Lib/plat-mac/terminalcommand.py @@ -35,7 +35,7 @@ def run(command): try: theEvent.AESend(SEND_MODE, kAENormalPriority, kAEDefaultTimeout) - except AE.Error, why: + except AE.Error as why: if why[0] != -600: # Terminal.app not yet running raise os.system(START_TERMINAL) |