On Mon, Jun 1, 2015 at 6:00 PM, Antoine Pitrou <solip...@pitrou.net> wrote: [...] > I think we have been laxist with additions to the stable ABI: > apparently, they should be conditioned on the API version requested by > the user. For example, in pystate.h: > > #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 > /* New in 3.3 */ > PyAPI_FUNC(int) PyState_AddModule(PyObject*, struct PyModuleDef*); > PyAPI_FUNC(int) PyState_RemoveModule(struct PyModuleDef*); > #endif > > (those were added by Martin, so I assume he knew what he was doing :-)) > > This way, failing to restrict yourself to a given API version fails at > compile time, not at runtime. However, it's also more work to do so > when adding stuff, which is why we tend to skimp on it.
I see! I completely missed that memo. I filed a patch that wraps my 3.5 additions as issue 24365. I think this should be in the PEP, so people like me can find it. Does the attached wording look good?
diff --git a/pep-0384.txt b/pep-0384.txt index f042478..311bae4 100644 --- a/pep-0384.txt +++ b/pep-0384.txt @@ -360,6 +360,19 @@ whether their modules conform to the ABI. To avoid users having to rewrite their type definitions, a script to convert C source code containing type definitions will be provided [3]_. +Considerations for CPython developers +===================================== + +When making additions to the stable ABI, the new definitions should be wrapped +in a preprocessor conditional block that limits their visibility to +a minimum stable ABI version. For example:: + + #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 + /* New in 3.3 */ + PyAPI_FUNC(int) PyState_AddModule(PyObject*, struct PyModuleDef*); + PyAPI_FUNC(int) PyState_RemoveModule(struct PyModuleDef*); + #endif + References ==========
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com