mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
parent
9bab65c259
commit
e65282114e
10 changed files with 449 additions and 133 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue