[issue41313] OverflowError still raised when int limited in sys.maxsize

Mark Dickinson report at bugs.python.org
Thu Jul 16 04:17:57 EDT 2020


Mark Dickinson <dickinsm at gmail.com> added the comment:

The recursion depth and recursion limit are stored internally as C ints, so yes, 2**31 - 1 = 2147483647 is the maximum value that you can pass to `sys.setrecursionlimit` that won't fail immediately.

But it's unclear why you'd ever want to set the recursion limit that high. What's your goal here? Are you looking for a way to effectively disable that recursion limit altogether? If so, can you explain the use-case?

Note that the recursion limit is there to prevent your code from exhausting the C stack and segfaulting as a result: simply setting that limit to a huge value won't (by itself) allow you to run arbitrarily deeply nested recursions. On my machine, without the protection of the recursion limit, a simple recursive call segfaults at around a depth of 30800.

----------
nosy: +mark.dickinson

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41313>
_______________________________________


More information about the Python-bugs-list mailing list