[Python-Dev] Preventing 1.5 extensions crashing under 1.6/2.0 Python
M.-A. Lemburg
mal@lemburg.com
Tue, 18 Jul 2000 10:07:24 +0200
Fredrik Lundh wrote:
>
> gordon wrote:
> > initXXX() (normally) calls Py_InitModule4, so it would be the
> > one in whatever XXXmodule loaded.
>
> exactly my point...
>
> so, would this work?
Hmm, as I see it this patch would have to be in 1.5.2 to be
of any use for the problem mentioned in the subject line:
the 1.5 extension links against python15.dll and
thus calls the Py_InitModule() of that DLL, not the one in
python20.dll which would have the logic below.
Anyway, it's a good start for future versions of Python.
> Index: Python/modsupport.c
> ===================================================================
> 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 != 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"...
--
Marc-Andre Lemburg
______________________________________________________________________
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/