[Python-Dev] Avoiding reference leaks in heap types with custom tp_dealloc

Petr Viktorin encukou at gmail.com
Tue Jun 2 21:09:52 CEST 2015


On Mon, Jun 1, 2015 at 6:00 PM, Antoine Pitrou <solipsis at 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?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pep384.patch
Type: text/x-patch
Size: 860 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150602/a6360209/attachment.bin>


More information about the Python-Dev mailing list