mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #19235: Add new RecursionError exception. Patch by Georg Brandl.
This commit is contained in:
parent
27be130ec7
commit
f488fb422a
31 changed files with 101 additions and 69 deletions
|
@ -258,18 +258,18 @@ class TestIsInstanceIsSubclass(unittest.TestCase):
|
|||
self.assertEqual(True, issubclass(str, (str, (Child, NewChild, str))))
|
||||
|
||||
def test_subclass_recursion_limit(self):
|
||||
# make sure that issubclass raises RuntimeError before the C stack is
|
||||
# make sure that issubclass raises RecursionError before the C stack is
|
||||
# blown
|
||||
self.assertRaises(RuntimeError, blowstack, issubclass, str, str)
|
||||
self.assertRaises(RecursionError, blowstack, issubclass, str, str)
|
||||
|
||||
def test_isinstance_recursion_limit(self):
|
||||
# make sure that issubclass raises RuntimeError before the C stack is
|
||||
# make sure that issubclass raises RecursionError before the C stack is
|
||||
# blown
|
||||
self.assertRaises(RuntimeError, blowstack, isinstance, '', str)
|
||||
self.assertRaises(RecursionError, blowstack, isinstance, '', str)
|
||||
|
||||
def blowstack(fxn, arg, compare_to):
|
||||
# Make sure that calling isinstance with a deeply nested tuple for its
|
||||
# argument will raise RuntimeError eventually.
|
||||
# argument will raise RecursionError eventually.
|
||||
tuple_arg = (compare_to,)
|
||||
for cnt in range(sys.getrecursionlimit()+5):
|
||||
tuple_arg = (tuple_arg,)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue