[Python-Dev] Preventing 1.5 extensions crashing under 1.6/2.0 Python (original) (raw)
M.-A. Lemburg mal@lemburg.com
Thu, 03 Aug 2000 11:55:57 +0200
- Previous message: [Python-Dev] Preventing 1.5 extensions crashing under 1.6/2.0 Python
- Next message: [Python-Dev] Preventing 1.5 extensions crashing under 1.6/2.0 Python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum wrote:
> Change the init function name to a new name PythonExtensionInit say. > Pass in the API version for the extension writer to check. If the > version is bad for this extension returns without calling any python > functions. Add a return code that is true if compatible, false if not. > If compatible the extension can use python functions and report and > problems it wishes. > > int PythonExtensionInitXXX( int invokingpythonapiversion ) > { > if( invokingpythonapiversion != PYTHONAPIVERSION ) > { > /* python will report that the module is incompatible */ > return 0; > } > > /* setup module for XXX ... */ > > /* say this extension is compatible with the invoking python */ > return 1; > } > > All 1.5 extensions fail to load on later python 2.0 and later. > All 2.0 extensions fail to load on python 1.5. > > All new extensions work only with python of the same API version. > > Document that failure to setup a module could mean the extension is > incompatible with this version of python. > > Small code change in python core. But need to tell extension writers > what the new interface is and update all extensions within the python > CVS tree. I sort-of like this idea -- at least at the +0 level.
I sort of dislike the idea ;-)
It introduces needless work for hundreds of extension writers and effectively prevents binary compatibility for future versions of Python: not all platforms have the problems of the Windows platform and extensions which were compiled against a different API version may very well still work with the new Python version -- e.g. the dynamic loader on Linux is very well capable of linking the new Python version against an extension compiled for the previous Python version.
If all this is really necessary, I'd at least suggest adding macros emulating the old Py_InitModule() APIs, so that extension writers don't have to edit their code just to get it recompiled.
BTW, the subject line doesn't have anything to do with the proposed solutions in this thread... they all crash Python or the extensions in some way, some nicer, some not so nice ;-)
-- Marc-Andre Lemburg
Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
- Previous message: [Python-Dev] Preventing 1.5 extensions crashing under 1.6/2.0 Python
- Next message: [Python-Dev] Preventing 1.5 extensions crashing under 1.6/2.0 Python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]