[Cython] Refcount error with fused types in classes

mark florisson markflorisson88 at gmail.com
Sun Mar 17 17:51:37 CET 2013


On 17 March 2013 16:15, Pauli Virtanen <pav at iki.fi> wrote:
> Hi,
>
> Here's a snippet demonstrating a refcount error with fused types inside
> classes:
>
> ---------8<---------
> cimport cython
>
> ctypedef fused some_t:
>     int
>     double
>
> class Foo(object):
>     def bar(self, some_t x):
>         pass
>
> cdef extern from "Python.h":
>     int Py_REFCNT(object)
>
> def main():
>     x = Foo()
>     print "before:", Py_REFCNT(x)
>     x.bar(1.0) # spuriously increments refcount of `x`
>     print "after: ", Py_REFCNT(x)
> ---------8<---------
>
>
> --
> Pauli Virtanen
>
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel

Thanks, I pushed a fix here: https://github.com/markflorisson88/cython
(fd4853d202b13a92).


More information about the cython-devel mailing list