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:
Guido van Rossum 2007-01-10 16:19:56 +00:00
parent 893523e80a
commit b940e113bf
295 changed files with 817 additions and 743 deletions

View file

@ -153,7 +153,7 @@ def main():
try:
opts, args = getopt.getopt(sys.argv[1:], 'Rd:m:nqr:t:vxa')
except getopt.error, msg:
except getopt.error as msg:
sys.stdout = sys.stderr
print msg
print __doc__%globals()
@ -335,7 +335,7 @@ class Checker:
rp.set_url(url)
try:
rp.read()
except (OSError, IOError), msg:
except (OSError, IOError) as msg:
self.note(1, "I/O error parsing %s: %s", url, msg)
def run(self):
@ -402,7 +402,7 @@ class Checker:
return
try:
page = self.getpage(url_pair)
except sgmllib.SGMLParseError, msg:
except sgmllib.SGMLParseError as msg:
msg = self.sanitize(msg)
self.note(0, "Error parsing %s: %s",
self.format_url(url_pair), msg)
@ -541,7 +541,7 @@ class Checker:
url, fragment = url_pair
try:
return self.urlopener.open(url)
except (OSError, IOError), msg:
except (OSError, IOError) as msg:
msg = self.sanitize(msg)
self.note(0, "Error %s", msg)
if self.verbose > 0:
@ -759,7 +759,7 @@ class MyURLopener(urllib.FancyURLopener):
return self.open_file(url + "index.html")
try:
names = os.listdir(path)
except os.error, msg:
except os.error as msg:
exc_type, exc_value, exc_tb = sys.exc_info()
raise IOError, msg, exc_tb
names.sort()