mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00: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
|
@ -94,7 +94,7 @@ class ModuleBrowserTreeItem(TreeItem):
|
|||
return []
|
||||
try:
|
||||
dict = pyclbr.readmodule_ex(name, [dir] + sys.path)
|
||||
except ImportError, msg:
|
||||
except ImportError as msg:
|
||||
return []
|
||||
items = []
|
||||
self.classes = {}
|
||||
|
|
|
@ -505,7 +505,7 @@ class EditorWindow(object):
|
|||
# XXX Ought to insert current file's directory in front of path
|
||||
try:
|
||||
(f, file, (suffix, mode, type)) = _find_module(name)
|
||||
except (NameError, ImportError), msg:
|
||||
except (NameError, ImportError) as msg:
|
||||
tkMessageBox.showerror("Import error", str(msg), parent=self.text)
|
||||
return
|
||||
if type != imp.PY_SOURCE:
|
||||
|
|
|
@ -82,7 +82,7 @@ class GrepDialog(SearchDialogBase):
|
|||
for fn in list:
|
||||
try:
|
||||
f = open(fn)
|
||||
except IOError, msg:
|
||||
except IOError as msg:
|
||||
print msg
|
||||
continue
|
||||
lineno = 0
|
||||
|
@ -110,7 +110,7 @@ class GrepDialog(SearchDialogBase):
|
|||
def findfiles(self, dir, base, rec):
|
||||
try:
|
||||
names = os.listdir(dir or os.curdir)
|
||||
except os.error, msg:
|
||||
except os.error as msg:
|
||||
print msg
|
||||
return []
|
||||
list = []
|
||||
|
|
|
@ -246,7 +246,7 @@ class IOBinding:
|
|||
f = open(filename,'rb')
|
||||
chars = f.read()
|
||||
f.close()
|
||||
except IOError, msg:
|
||||
except IOError as msg:
|
||||
tkMessageBox.showerror("I/O Error", str(msg), master=self.text)
|
||||
return False
|
||||
|
||||
|
@ -289,7 +289,7 @@ class IOBinding:
|
|||
# Next look for coding specification
|
||||
try:
|
||||
enc = coding_spec(chars)
|
||||
except LookupError, name:
|
||||
except LookupError as name:
|
||||
tkMessageBox.showerror(
|
||||
title="Error loading the file",
|
||||
message="The encoding '%s' is not known to this Python "\
|
||||
|
@ -380,7 +380,7 @@ class IOBinding:
|
|||
f.flush()
|
||||
f.close()
|
||||
return True
|
||||
except IOError, msg:
|
||||
except IOError as msg:
|
||||
tkMessageBox.showerror("I/O Error", str(msg),
|
||||
master=self.text)
|
||||
return False
|
||||
|
@ -400,7 +400,7 @@ class IOBinding:
|
|||
try:
|
||||
enc = coding_spec(chars)
|
||||
failed = None
|
||||
except LookupError, msg:
|
||||
except LookupError as msg:
|
||||
failed = msg
|
||||
enc = None
|
||||
if enc:
|
||||
|
|
|
@ -380,7 +380,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
|||
try:
|
||||
self.rpcclt = MyRPCClient(addr)
|
||||
break
|
||||
except socket.error, err:
|
||||
except socket.error as err:
|
||||
pass
|
||||
else:
|
||||
self.display_port_binding_error()
|
||||
|
@ -389,7 +389,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
|||
self.rpcclt.listening_sock.settimeout(10)
|
||||
try:
|
||||
self.rpcclt.accept()
|
||||
except socket.timeout, err:
|
||||
except socket.timeout as err:
|
||||
self.display_no_subprocess_error()
|
||||
return None
|
||||
self.rpcclt.register("stdin", self.tkconsole)
|
||||
|
@ -423,7 +423,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
|||
self.spawn_subprocess()
|
||||
try:
|
||||
self.rpcclt.accept()
|
||||
except socket.timeout, err:
|
||||
except socket.timeout as err:
|
||||
self.display_no_subprocess_error()
|
||||
return None
|
||||
self.transfer_path()
|
||||
|
@ -1324,7 +1324,7 @@ def main():
|
|||
startup = False
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "c:deihnr:st:")
|
||||
except getopt.error, msg:
|
||||
except getopt.error as msg:
|
||||
sys.stderr.write("Error: %s\n" % str(msg))
|
||||
sys.stderr.write(usage_msg)
|
||||
sys.exit(2)
|
||||
|
|
|
@ -66,13 +66,13 @@ class ScriptBinding:
|
|||
f = open(filename, 'r')
|
||||
try:
|
||||
tabnanny.process_tokens(tokenize.generate_tokens(f.readline))
|
||||
except tokenize.TokenError, msg:
|
||||
except tokenize.TokenError as msg:
|
||||
msgtxt, (lineno, start) = msg
|
||||
self.editwin.gotoline(lineno)
|
||||
self.errorbox("Tabnanny Tokenizing Error",
|
||||
"Token Error: %s" % msgtxt)
|
||||
return False
|
||||
except tabnanny.NannyNag, nag:
|
||||
except tabnanny.NannyNag as nag:
|
||||
# The error messages from tabnanny are too confusing...
|
||||
self.editwin.gotoline(nag.get_lineno())
|
||||
self.errorbox("Tab/space error", indent_message)
|
||||
|
@ -97,7 +97,7 @@ class ScriptBinding:
|
|||
try:
|
||||
# If successful, return the compiled code
|
||||
return compile(source, filename, "exec")
|
||||
except (SyntaxError, OverflowError), err:
|
||||
except (SyntaxError, OverflowError) as err:
|
||||
try:
|
||||
msg, (errorfilename, lineno, offset, line) = err
|
||||
if not errorfilename:
|
||||
|
|
|
@ -66,7 +66,7 @@ class SearchEngine:
|
|||
flags = flags | re.IGNORECASE
|
||||
try:
|
||||
prog = re.compile(pat, flags)
|
||||
except re.error, what:
|
||||
except re.error as what:
|
||||
try:
|
||||
msg, col = what
|
||||
except:
|
||||
|
|
|
@ -114,7 +114,7 @@ def manage_socket(address):
|
|||
try:
|
||||
server = MyRPCServer(address, MyHandler)
|
||||
break
|
||||
except socket.error, err:
|
||||
except socket.error as err:
|
||||
print>>sys.__stderr__,"IDLE Subprocess: socket error: "\
|
||||
+ err[1] + ", retrying...."
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue