From: Lisandro Dalcin Date: Wed, 25 Feb 2009 00:31:02 +0000 (-0300) Subject: fix reference leak in the capi export function, add testcase X-Git-Tag: 0.11.rc~39 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=35efaff73dd81c61de8f1ff006e7a17a25146d14;p=cython.git fix reference leak in the capi export function, add testcase --- diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 0e0bdf7e..d24dc489 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -2128,6 +2128,7 @@ static int __Pyx_ExportFunction(const char *name, void *f, const char *sig) { goto bad; if (PyDict_SetItemString(d, name, p) < 0) goto bad; + Py_DECREF(p); Py_DECREF(d); return 0; bad: diff --git a/tests/run/capiimpl.pyx b/tests/run/capiimpl.pyx new file mode 100644 index 00000000..e7ea7e2b --- /dev/null +++ b/tests/run/capiimpl.pyx @@ -0,0 +1,14 @@ +__doc__ = u""" +>>> import sys +>>> sys.getrefcount(Foo.__pyx_vtable__) +2 +>>> sys.getrefcount(__pyx_capi__['spam']) +2 +""" + +cdef public api class Foo [type FooType, object FooObject]: + cdef void bar(self): + pass + +cdef api void spam(): + pass