Implicit exception chaining via __context__ (PEP 3134).

Patch 3108 by Antooine Pitrou.
This commit is contained in:
Guido van Rossum 2008-06-14 20:20:24 +00:00
parent 973124fd70
commit b4fb6e4d27
4 changed files with 139 additions and 33 deletions

View file

@ -480,7 +480,12 @@ class ExceptionTests(unittest.TestCase):
inner_raising_func()
except:
raise KeyError
except KeyError:
except KeyError as e:
# We want to test that the except block above got rid of
# the exception raised in inner_raising_func(), but it
# also ends up in the __context__ of the KeyError, so we
# must clear the latter manually for our test to succeed.
e.__context__ = None
obj = None
obj = wr()
self.failUnless(obj is None, "%s" % obj)