[Cython] Bug report with 0.16 RC

Wes McKinney wesmckinn at gmail.com
Tue Apr 3 23:18:41 CEST 2012


I don't have a Trac account yet, but wanted to report this bug with
the 0.16 RC. This function worked fine under 0.15.1:


@cython.wraparound(False)
@cython.boundscheck(False)
def is_lexsorted(list list_of_arrays):
    cdef:
        int i
        Py_ssize_t n, nlevels
        int32_t k, cur, pre
        ndarray arr

    nlevels = len(list_of_arrays)
    n = len(list_of_arrays[0])

    cdef int32_t **vecs = <int32_t**> malloc(nlevels * sizeof(int32_t*))
    for i from 0 <= i < nlevels:
        vecs[i] = <int32_t *> (<ndarray> list_of_arrays[i]).data
    # assume uniqueness??

    for i from 1 <= i < n:
        for k from 0 <= k < nlevels:
            cur = vecs[k][i]
            pre = vecs[k][i-1]
            if cur == pre:
                continue
            elif cur > pre:
                break
            else:
                return False
    free(vecs)
    return True

gives this error:

python setup.py build_ext --inplace
running build_ext
cythoning pandas/src/tseries.pyx to pandas/src/tseries.c

Error compiling Cython file:
------------------------------------------------------------
...
    nlevels = len(list_of_arrays)
    n = len(list_of_arrays[0])

    cdef int32_t **vecs = <int32_t**> malloc(nlevels * sizeof(int32_t*))
    for i from 0 <= i < nlevels:
        vecs[i] = <int32_t *> (<ndarray> list_of_arrays[i]).data
                                                          ^
------------------------------------------------------------

pandas/src/groupby.pyx:120:59: Compiler crash in AnalyseExpressionsTransform

ModuleNode.body = StatListNode(tseries.pyx:1:0)
StatListNode.stats[52] = StatListNode(groupby.pyx:4:0)
StatListNode.stats[6] = CompilerDirectivesNode(groupby.pyx:109:0)
CompilerDirectivesNode.body = StatListNode(groupby.pyx:109:0)
StatListNode.stats[0] = DefNode(groupby.pyx:109:0,
    modifiers = [...]/0,
    name = u'is_lexsorted',
    num_required_args = 1,
    py_wrapper_required = True,
    reqd_kw_flags_cname = '0',
    used = True)
File 'Nodes.py', line 342, in analyse_expressions:
StatListNode(groupby.pyx:110:4,
    is_terminator = True)
File 'Nodes.py', line 342, in analyse_expressions:
StatListNode(groupby.pyx:119:4)
File 'Nodes.py', line 6054, in analyse_expressions:
ForFromStatNode(groupby.pyx:119:4,
    relation1 = u'<=',
    relation2 = u'<')
File 'Nodes.py', line 342, in analyse_expressions:
StatListNode(groupby.pyx:120:18)
File 'Nodes.py', line 4778, in analyse_expressions:
SingleAssignmentNode(groupby.pyx:120:18)
File 'Nodes.py', line 4883, in analyse_types:
SingleAssignmentNode(groupby.pyx:120:18)
File 'ExprNodes.py', line 7079, in analyse_types:
TypecastNode(groupby.pyx:120:18,
    result_is_used = True,
    use_managed_ref = True)
File 'ExprNodes.py', line 4274, in analyse_types:
AttributeNode(groupby.pyx:120:59,
    attribute = u'data',
    initialized_check = True,
    is_attribute = 1,
    member = u'data',
    needs_none_check = True,
    op = '->',
    result_is_used = True,
    use_managed_ref = True)
File 'ExprNodes.py', line 4360, in analyse_as_ordinary_attribute:
AttributeNode(groupby.pyx:120:59,
    attribute = u'data',
    initialized_check = True,
    is_attribute = 1,
    member = u'data',
    needs_none_check = True,
    op = '->',
    result_is_used = True,
    use_managed_ref = True)
File 'ExprNodes.py', line 4436, in analyse_attribute:
AttributeNode(groupby.pyx:120:59,
    attribute = u'data',
    initialized_check = True,
    is_attribute = 1,
    member = u'data',
    needs_none_check = True,
    op = '->',
    result_is_used = True,
    use_managed_ref = True)

Compiler crash traceback from this point on:
  File "/home/wesm/code/repos/cython/Cython/Compiler/ExprNodes.py",
line 4436, in analyse_attribute
    replacement_node = numpy_transform_attribute_node(self)
  File "/home/wesm/code/repos/cython/Cython/Compiler/NumpySupport.py",
line 18, in numpy_transform_attribute_node
    numpy_pxd_scope = node.obj.entry.type.scope.parent_scope
AttributeError: 'TypecastNode' object has no attribute 'entry'


More information about the cython-devel mailing list