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

Gordon McMillan gmcm@hypernet.com
Mon, 17 Jul 2000 22:38:37 -0400


Mark Hammond wrote:

> [Fredrik]
> > I'm probably missing something here, but is there any reason
> > you cannot add this code to Py_InitModule4 instead:
> >
> >    PyObject *m, *d, *v;
> >    PyMethodDef *ml;
> > + if (!Py_IsInitialized())
> > +    Py_FatalError("Bad Python version"); /* Never returns */
> 
> Py_InitModule4() is inside Pythonxx.dll - so it _will_ be
> initialized.  The point of putting this code inside the .pyd is
> that the .pyd will be calling the Py_IsInitialized() from
> Python15.dll - and this DLL has never been initialized.  Putting
> it inside Py_InitModule4() will never trigger an error...

Florida sun getting to you? Or the teenage girls? Or just being 
in the wrong hemisphere (so all the blood rushes to your feet)?

initXXX() (normally) calls Py_InitModule4, so it would be the 
one in whatever XXXmodule loaded.

- Gordon