implement chained exception tracebacks

patch from Antoine Pitrou #3112
This commit is contained in:
Benjamin Peterson 2008-07-15 15:32:09 +00:00
parent 9bab65c259
commit e65282114e
10 changed files with 449 additions and 133 deletions

View file

@ -278,6 +278,30 @@ class TestContext(unittest.TestCase):
else:
self.fail("No exception raised")
def test_cycle_broken(self):
# Self-cycles (when re-raising a caught exception) are broken
try:
try:
1/0
except ZeroDivisionError as e:
raise e
except ZeroDivisionError as e:
self.failUnless(e.__context__ is None, e.__context__)
def test_reraise_cycle_broken(self):
# Non-trivial context cycles (through re-raising a previous exception)
# are broken too.
try:
try:
xyzzy
except NameError as a:
try:
1/0
except ZeroDivisionError:
raise a
except NameError as e:
self.failUnless(e.__context__.__context__ is None)
class TestRemovedFunctionality(unittest.TestCase):
def test_tuples(self):