You are using the exit()
function the Python site
module sets for use in the interactive interpreter.
This is Python code you are calling, not C code. This triggers the recursion depth exception handler a few more times until you are far enough away from the stack limit.
When you are right up against the limit, trying to call exit()
fails because you hit the stack limit. So a RuntimeError
is raised, falling back a call to 998
. Here you try to call exit()
again, which tries to do some more work raising the RuntimeError
again, falling back another level, etc. until there is enough stack space left to finally call raise SystemExit()
in the python function.
Use sys.exit()
instead to avoid adding more strain to the stack.
Or, for future reference, use the sys.getrecursionlimit()
function to just ask Python directly what the limit is.