Hi, 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 have not posted the complete code since the .pyx is around 50k lines long, but the offending method looks like this, and the problematic variable is _3_perm in line 4: --------------- cdef _toStringArray__3JJ_3S(self,numpy.ndarray[numpy.int64_t,ndim=1] _0_subi,numpy.int64_t _1_dstidx,numpy.ndarray[object,ndim=1] _2_result): assert _0_subi is None or isinstance(_0_subi,numpy.ndarray) assert _2_result is None or isinstance(_2_result,numpy.ndarray) cdef numpy.ndarray[numpy.int64_t,ndim=1] _3_perm cdef numpy.float64_t _4_c cdef numpy.int32_t _5_b cdef numpy.int32_t _6_ni cdef numpy.int64_t _7_i cdef numpy.int32_t _8_p cdef mosek_fusion_Utils_StringBuffer _9_sb for _10_i in xrange(0,(_0_subi).shape[0]): if ((_0_subi[_10_i] < 0) or (_0_subi[_10_i] >= (self.shape.size))): raise mosek_fusion_IndexError_ctor_S("Constraint index out of bounds") if (((_0_subi).shape[0] + _1_dstidx) > (_2_result).shape[0]): raise mosek_fusion_LengthError_ctor_S("Result array is too small to hold the result") _9_sb=mosek.fusion.Utils.StringBuffer() _8_p=0 if True: for _11_k in xrange(0,(_0_subi).shape[0]): _7_i=_0_subi[_11_k] _6_ni=self.nativeindexes[_7_i] _5_b=_8_p while ((_8_p < ((self.cache.subi)).shape[0]) and ((self.cache.subi)[_8_p] == _7_i)): _8_p += 1 _9_sb._clear_()._a_S(self.name)._a_S("[")._a_S(self.shape.indexToString(_7_i))._a_S("] : ") for _12_j in xrange(_5_b,_8_p): _4_c=(self.cache.cof)[_12_j] if (_4_c > 0): _9_sb._a_S(" + ")._a_D(_4_c)._a_S(" ") elif (_4_c < 0): _9_sb._a_S(" - ")._a_D((- _4_c))._a_S(" ") self.model._nativeVarToStr_ILmosek_4fusion_4Utils_4StringBuffer_2((self.cache.subj)[_12_j],_9_sb) if (self.cache_bfix != None): if (self.cache_bfix[_7_i] > 0): _9_sb._a_S(" + ")._a_D(self.cache_bfix[_7_i]) elif (self.cache_bfix[_7_i] < 0): _9_sb._a_S(" + ")._a_D(self.cache_bfix[_7_i]) _9_sb._a_S(" ") self._domainToString_JLmosek_4fusion_4Utils_4StringBuffer_2(_7_i,_9_sb) _2_result[(numpy.int64(_11_k) + _1_dstidx)] = _9_sb._toString_() else: _3_perm=numpy.zeros(((_0_subi).shape[0],), dtype=numpy.dtype(numpy.int64)) mosek_fusion_CommonTools_argQsort__3J_3J_3JJJ(_3_perm,_0_subi,None,0l,(_0_subi).shape[0]) --------------- -- Ulf Worsøe Mosek ApS ulf.wor...@mosek.com www.mosek.com
_______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel