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

@ -148,7 +148,7 @@ def framework_find(fn, executable_path=None, env=None):
"""
try:
return dyld_find(fn, executable_path=executable_path, env=env)
except ValueError, e:
except ValueError as e:
pass
fmwk_index = fn.rfind('.framework')
if fmwk_index == -1:

View file

@ -57,12 +57,12 @@ def get_tests(package, mask, verbosity):
for modname in find_package_modules(package, mask):
try:
mod = __import__(modname, globals(), locals(), ['*'])
except ResourceDenied, detail:
except ResourceDenied as detail:
skipped.append(modname)
if verbosity > 1:
print >> sys.stderr, "Skipped %s: %s" % (modname, detail)
continue
except Exception, detail:
except Exception as detail:
print >> sys.stderr, "Warning: could not import %s: %s" % (modname, detail)
continue
for name in dir(mod):

View file

@ -191,7 +191,7 @@ class BitFieldTest(unittest.TestCase):
def get_except(self, func, *args, **kw):
try:
func(*args, **kw)
except Exception, detail:
except Exception as detail:
return detail.__class__, str(detail)
def test_mixed_1(self):

View file

@ -313,7 +313,7 @@ class StructureTestCase(unittest.TestCase):
def get_except(self, func, *args):
try:
func(*args)
except Exception, detail:
except Exception as detail:
return detail.__class__, str(detail)
@ -388,7 +388,7 @@ class TestRecursiveStructure(unittest.TestCase):
try:
Recursive._fields_ = [("next", Recursive)]
except AttributeError, details:
except AttributeError as details:
self.failUnless("Structure or union cannot contain itself" in
str(details))
else:
@ -405,7 +405,7 @@ class TestRecursiveStructure(unittest.TestCase):
try:
Second._fields_ = [("first", First)]
except AttributeError, details:
except AttributeError as details:
self.failUnless("_fields_ is final" in
str(details))
else:

View file

@ -60,12 +60,12 @@ elif os.name == "posix":
finally:
try:
os.unlink(outfile)
except OSError, e:
except OSError as e:
if e.errno != errno.ENOENT:
raise
try:
os.unlink(ccout)
except OSError, e:
except OSError as e:
if e.errno != errno.ENOENT:
raise
res = re.search(expr, trace)