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

Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Tue, 8 Aug 2000 17:10:28 +0200


mark wrote:
> So I think that the adoption of our half-solution (ie, we are really =
only
> forcing a better error message - not even getting a traceback to =
indicate
> _which_ module fails)

note that the module name is available to the Py_InitModule4
module (for obvious reasons ;-), so it's not that difficult to
improve the error message.

how about:

...

static char not_initialized_error[] =3D
"ERROR: Module %.200s loaded an uninitialized interpreter!\n\
  This Python has API version %d, module %.200s has version %d.\n";

...

    if (!Py_IsInitialized()) {
        char message[500];
        sprintf(message, not_initialized_error, name, =
PYTHON_API_VERSION,
            name, module_api_version)
        Py_FatalError(message);
    }

</F>