[Python-Dev] Preventing 1.5 extensions crashing under 1.6/2.0 Python

Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Fri, 4 Aug 2000 10:30:25 +0200


thomas wrote:
> > +       if (!Py_IsInitialized())
> > +               Py_FatalError("Interpreter not initialized (version
>=20
> Wasn't there a problem with this, because the 'Py_FatalError()' would =
be the
> one in the uninitialized library and thus result in the same tstate =
error ?

you mean this one:

  Py_FatalError("PyThreadState_Get: no current thread");

> Perhaps it needs a separate error message, that avoids the usual =
Python
> cleanup and trickery and just prints the error message and exits ?

void
Py_FatalError(char *msg)
{
 fprintf(stderr, "Fatal Python error: %s\n", msg);
#ifdef macintosh
 for (;;);
#endif
#ifdef MS_WIN32
 OutputDebugString("Fatal Python error: ");
 OutputDebugString(msg);
 OutputDebugString("\n");
#ifdef _DEBUG
 DebugBreak();
#endif
#endif /* MS_WIN32 */
 abort();
}

</F>