If I understand the code correct Python 2.6 has the same value for PYTHON_API_VERSION, even though extensions are not compatible. In particular: when you compile an extension that uses PyInt_Check with python2.6 and load that extension with python 2.5 you will not get a version warning from Py_InitModule4 and you will also not get the right answers from PyInt_Check. This due to PyType_FastSubclass (in python 2.6) which tests flags in the type structure that are not initiazed in 2.5. That is a change in the ABI and hence should be accompanied by increasing PYTHON_API_VERSION. This is technically a bug in 2.6, but I'm not selecting that version in the list because increasing PYTHON_API_VERSION in 2.6.x would break existing installations when they upgrade.
Is PYTHON_API_VERSION actually useful right now? It seems to me that we need Martin's ABI stability PEP to be implemented before extension modules can be safely shared between several non-bugfix releases.
> Is PYTHON_API_VERSION actually useful right now? It seems to me that > we need Martin's ABI stability PEP to be implemented before extension > modules can be safely shared between several non-bugfix releases. Today, PYTHON_API_VERSION primarily serves as a check that the extension you load had been compiled for the Python release that its being loaded into. We promise ABI stability across bug fix releases for the same feature release, so yes, it is useful. The original motivation (allowing to share extensions across feature releases) was last relevant in the 1.x series, IIRC.
But should PYTHON_API_VERSION be increased for the 2.7 release? I think it should because of the binary incompatible differences between 2.5 and 2.6. In a perfect world that would have resulted in an increase of PYTHON_API_VERSION for the 2.6.0 release, but that's something that slipped through the cracks. By increasing the value in 2.7.0 users that switch from 2.5 to 2.7 get warnings that should help then find why their compiled extension stopped working (users migrating from 2.6 to 2.7 would also get the warning while it is technically not necessary, but that's harmless because you shouldn't reuse extensions anyway). The primary reason for posting this issue was that a colleague ran into this problem: he compiled an extension on a machine with python2.5 and ran the result on a machine with python2.6 and that misteriously didn't work (in his defense: he thought that both machines ran the same version of python). A warning at import would have made it more clear what was going wrong.