You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sys.setrecursionlimit(2**30) breaks interactive shell in Python >=3.3.
This bug does not occur during non-interactive execution of scripts / modules.
This bug does not occur in versions of Python older than 3.3.
This bug occurs only for some range of values of recursion limit. There are higher values, which do not cause this bug.
sys.setrecursionlimit(2**31), as expected, raises OverflowError.
Values like 2**31-1 (i.e. 2147483647) cause no problem:
$ python3.4 -q
>>> import sys
>>> sys.setrecursionlimit(2**31)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: signed integer is greater than maximum
>>> sys.setrecursionlimit(2**31-1)
>>> sys.getrecursionlimit()
2147483647
>>> 0
0
>>>
Lower limit of values of recursion limit, which cause this bug: 715827883 == 2**29 + 2**27 + 2**25 + 2**23 + 2**21 + 2**19 + 2**17 + 2**15 + 2**13 + 2**11 + 2**9 + 2**7 + 2**5 + 2**3 + 2**1 + 1
Upper limit of values of recursion limit, which cause this bug: 1431655765 == 2**30 + 2**28 + 2**26 + 2**24 + 2**22 + 2**20 + 2**18 + 2**16 + 2**14 + 2**12 + 2**10 + 2**8 + 2**6 + 2**4 + 2**2 + 1
Example of this bug:
$ python3.4 -q
>>> import sys
>>> sys.setrecursionlimit(2**30)
>>> 0
RuntimeError: maximum recursion depth exceeded during compilation
>>> "a"
RuntimeError: maximum recursion depth exceeded during compilation
>>>
RuntimeError: maximum recursion depth exceeded during compilation
>>>
RuntimeError occurs for each line (even empty). Ctrl+D still works.
Activity
Arfrever commentedon Sep 27, 2013
sys.setrecursionlimit(2**30) breaks interactive shell in Python >=3.3.
This bug does not occur during non-interactive execution of scripts / modules.
This bug does not occur in versions of Python older than 3.3.
This bug occurs only for some range of values of recursion limit. There are higher values, which do not cause this bug.
sys.setrecursionlimit(2**31), as expected, raises OverflowError.
Values like 2**31-1 (i.e. 2147483647) cause no problem:
Lower limit of values of recursion limit, which cause this bug: 715827883 == 2**29 + 2**27 + 2**25 + 2**23 + 2**21 + 2**19 + 2**17 + 2**15 + 2**13 + 2**11 + 2**9 + 2**7 + 2**5 + 2**3 + 2**1 + 1
Upper limit of values of recursion limit, which cause this bug: 1431655765 == 2**30 + 2**28 + 2**26 + 2**24 + 2**22 + 2**20 + 2**18 + 2**16 + 2**14 + 2**12 + 2**10 + 2**8 + 2**6 + 2**4 + 2**2 + 1
Example of this bug:
RuntimeError occurs for each line (even empty). Ctrl+D still works.
I use 64-bit GNU/Linux.
python-dev commentedon Sep 27, 2013
New changeset c3df31cbcd0a by Benjamin Peterson in branch '3.3':
don't scale compiler stack frames if the recursion limit is huge (closes bpo-19098)
http://hg.python.org/cpython/rev/c3df31cbcd0a
New changeset 9a7ec433bf59 by Benjamin Peterson in branch 'default':
merge 3.3 (bpo-19098)
http://hg.python.org/cpython/rev/9a7ec433bf59