Message263860
Interesting idea. We avoid the problem by adding something like the following to run.py
_setrecursionlimit = sys.setrecursionlimit
def setrecursionlimit(n):
_setrecursionlimit(max(n, 50))
sys.setrecursionlimit = setrecursionlimit
This works when entered interactively, and I presume it would within run.py. For _setrecursionlimit to be accessible from user code (to reverse the monkey patching), it would have to be attached to the function as an attribute.
setrecursionlimit.original = _setrecursionlimit
Though user-friendly for most users, this would make IDLE execute code differently from raw Python. The builtin has a lower limit, based on the current stack depth, but it raises instead of setting a higher limit. I presume we could use len(inspect.stack()) to get the current 'recursion depth', and add, say, 30 rather than 3. (The current error message could be more helpful.)
>>> sys.setrecursionlimit(3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RecursionError: cannot set the recursion limit to 3 at the recursion depth 1: the limit is too low
>>> sys.setrecursionlimit(4)
>>> f()
>>>
>>> def f():
... print('f')
... f()
...
>>> f()
>>>
The call to f seems to be silently ignored. This does not seem helpful.
Whatever we do, I would mention it in a revision of the proposed paragraph above. |
|
Date |
User |
Action |
Args |
2016-04-20 20:20:09 | terry.reedy | set | recipients:
+ terry.reedy, serhiy.storchaka |
2016-04-20 20:20:09 | terry.reedy | set | messageid: <1461183609.61.0.881469081182.issue26806@psf.upfronthosting.co.za> |
2016-04-20 20:20:09 | terry.reedy | link | issue26806 messages |
2016-04-20 20:20:09 | terry.reedy | create | |
|