Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46371

Re: Fatal Python error

References <CAN1F8qXPEM4B=2e7KOhWeTKzxmeeb_w_S97wYiHCMXH3jfzL6g@mail.gmail.com>
Date 2013-05-29 09:30 -0300
Subject Re: Fatal Python error
From Marcel Rodrigues <marcelgmr@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2351.1369830668.3114.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

I just tried your code with similar results: it does nothing on PyPy
2.0.0-beta2 and Python 2.7.4. But on Python 3.3.1 it caused core dump.
It's a little weird but so is the code. You have defined a function that
calls itself unconditionally. This will cause a stack overflow, which is a
RuntimeError.
 Since you are handling this very exception with a pass statement, we would
expect that no error occurs. But the fatal error message seems pretty
informative at this point: "Cannot recover from stack overflow.".

One thing to note is that while it's reasonable to handle exceptions that
happens at the level of your Python code, like a ValueError, it's not so
reasonable to try to handle something that may disturb the interpreter
itself in a lower level, like a stack overflow (I think that the stack used
by your code is the same stack used by the interpreter code, but I'm not
sure).


2013/5/29 Joshua Landau <joshua.landau.ws@gmail.com>

> Hello all, again. Instead of revising like I'm meant to be, I've been
> delving into a bit of Python and I've come up with this code:
>
> class ClassWithProperty:
>  @property
> def property(self):
> pass
>
> thingwithproperty = ClassWithProperty()
>
> def loop():
> try:
> thingwithproperty.property
>  except:
> pass
>
> loop()
>
> try:
> loop()
> except RuntimeError:
> pass
>
> As you will expect, this does nothing... on Python2.7 and PyPy. Python3.3
> prefers to spit out a "Fatal Python error: Cannot recover from stack
> overflow.", which seems a bit unexpected.
>
> Wuzzup with that?
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Fatal Python error Marcel Rodrigues <marcelgmr@gmail.com> - 2013-05-29 09:30 -0300

csiph-web