Created on 2011-12-21 05:54 by Ramchandra Apte, last changed 2011-12-24 22:45 by terry.reedy. This issue is now closed..
Python isn't crashing; it's bailing out of an impossible situation. It's not clear what the correct behavior is, since you're basically preventing Python from aborting the recursive behavior.
But Python 2 doesn't crash after running the code.
Oops, to reproduce this bug after running the code run "recurse()".
The behavior of Python 2 is not anymore correct than that of Python 3.
Well, I expect Python 3 to raise RuntimeError about recursion not to segfault.
There is no place for it to raise a RuntimeError which will continue to propogate!
With Python 2, I can inspect the error to see where it occurred using traceback. With Python 3, I'd need to use gdb.
@OP: As you yourself wrote, this is an abort, not a segfault. It is not a crash; it is a controlled exit of the Python executable.
@Benjamin: I don't really understand your reasoning: what is preventing Python to raise the error during the except clause?
Nothing, but that would be pointless; the recursion would just start again.
When I run this with 3.2.2 IDLE, from an edit window, I get an MSVC++ Runtime Library window: "Runtime Error! .../pythonw This application has requested termination in an unusual way...". When I close that, IDLE continues. So I would say that this is not a crash and not even a bug, but a particular choice of undefined behavior given infinite loop code. So we have no obligation to change it. I presume the change from 2.x is a side-effect of a change to improve something else.
def recurse(): recurse()
recurse()
does print "RuntimeError: maximum recursion depth exceeded" but only after printing a l o n g traceback. So for running from IDLE, I at least half prefer the immediate error box with no traceback.
@Terry
IDLE restarts python (like in the menu entry "Restart Shell") when the Python process dies no matter how the Python process dies.
So this issue is a valid bug.
This is identical to issue6028 and may be related to issue3555.
> Nothing, but that would be pointless; the recursion would just start again.
Why?
2011/12/24 Georg Brandl <report@bugs.python.org>:
>
> Georg Brandl <georg@python.org> added the comment:
>
>> Nothing, but that would be pointless; the recursion would just start again.
Because it would be caught in the function call above in the stack?
Would it?
2011/12/24 Georg Brandl <report@bugs.python.org>:
>
> Georg Brandl <georg@python.org> added the comment:
>
> Would it?
(<class 'Exception'>,)
Basically forget my last 3 messages.
@maniram I know what IDLE does. For the tracker, a 'bug' is a discrepancy between doc and behavior. According to the doc, a recursion loop should continue forever, just like an iteration loop ;=).
Anyway, Roger is right, this is a duplicate of #6028, which has at least a preliminary patch.