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

Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Tue, 18 Jul 2000 10:04:05 +0200


gordon wrote:
> initXXX() (normally) calls Py_InitModule4, so it would be the=20
> one in whatever XXXmodule loaded.

exactly my point...

so, would this work? =20

Index: Python/modsupport.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/python/python/dist/src/Python/modsupport.c,v
retrieving revision 2.48
diff -u -r2.48 modsupport.c
--- Python/modsupport.c 2000/07/09 03:09:56     2.48
+++ Python/modsupport.c 2000/07/18 07:55:03
@@ -51,6 +51,8 @@
 {
        PyObject *m, *d, *v;
        PyMethodDef *ml;
+       if (!Py_IsInitialized())
+               Py_FatalError("Interpreter not initialized (version =
mismatch?)");
        if (module_api_version !=3D PYTHON_API_VERSION)
                fprintf(stderr, api_version_warning,
                        name, PYTHON_API_VERSION, name, =
module_api_version);

"Fatal Python error: Interpreter not initialized" might not be too =
helpful,
but it's surely better than "PyThreadState_Get: no current thread"...

</F>