Ulf Worsoe, 30.04.2014 12:45: > I have encounterered a bug in the following situation with Cython 0.20.1: > > cdef funname(): > cdef numpy.ndarray[numpy.int32_t,ndim=1] myvar > if True: > ... block that never initializes myvar > else > ... block that initializes myvar > > The resulting C code does not declare the variable for the buffer object of > myvar (my guess is that cython detects that it is never used and drops it), > but the cleanup part of the C function contains code that frees the buffer, > and thus refers to a variable that was never declared.
I tried the following and it works for me, the buffer code gets properly discarded: ''' cimport numpy as np def disabled_usage(obj): cdef object[int, ndim=2] buf cdef np.ndarray[np.int32_t, ndim=1] buf2 if False: buf = obj elif not True: buf2 = obj return obj ''' Could you try to find a minimal example that shows the problem? Stefan _______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel