mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
GH-106057: Handle recursion errors in inline class calls properly. (GH-106108)
This commit is contained in:
parent
e1d45b8ed4
commit
24fb627ea7
4 changed files with 108 additions and 91 deletions
|
@ -740,6 +740,21 @@ class ClassTests(unittest.TestCase):
|
|||
class A(0, *range(1, 8), **d, foo='bar'): pass
|
||||
self.assertEqual(A, (tuple(range(8)), {'foo': 'bar'}))
|
||||
|
||||
def testClassCallRecursionLimit(self):
|
||||
class C:
|
||||
def __init__(self):
|
||||
self.c = C()
|
||||
|
||||
with self.assertRaises(RecursionError):
|
||||
C()
|
||||
|
||||
def add_one_level():
|
||||
#Each call to C() consumes 2 levels, so offset by 1.
|
||||
C()
|
||||
|
||||
with self.assertRaises(RecursionError):
|
||||
add_one_level()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue