[Python-Dev] Need to hook Py_FatalError

Josiah Carlson jcarlson at uci.edu
Tue May 3 18:14:28 CEST 2005


"m.u.k" <m.u.k.2 at gawab.com> wrote:
> Currently Py_FatalError only dumps the error to stderr and calls abort().
> When doing quirky things with the interpreter, it's so annoying that process 
> just terminates. Are there any reason why we still dont have a simple 
> callback to hook Py_FatalError.
> 
> PS. If the answer is "because no one needs/implemented...", I can volunteer.

In looking at the use of Py_FatalError in the Python Sources (it's a 10
meg tarball that is well worth the download), it looks as though its use
shows a Fatal error (hence the name).  Things like "Inconsistant
interned string state" or "Immortal interned string died" or "Can't
initialize type", etc.

Essentially, those errors generally signify "the internal state of
python is messed up", whether that be by C extension, or even a bug in
Python.  The crucial observation is that many of them have ambiguous
possible recoveries.  How do you come back from "Can't initialize type",
or even 'gc couldn't allocate "__del__"'?


When you have individual solutions to some subset of the uses of
Py_FatalError, then it would make sense to offer those solutions as a
replacement to Py_FatalError use in those situations (also showing that
the errors are not actually fatal), rather than to ask for a hook to
hook all (by definition) fatal errors.


 - Josiah



More information about the Python-Dev mailing list