bzrlib/_annotator_pyx.c:1859: error: ‘PyListObject’ has no member named ‘ob_item’

Bug #1240272 reported by Damien Nozay
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
New
Undecided
Unassigned

Bug Description

PyListObject should be opaque, e.g. nothing should try to access "ob_item"
This breaks compatibility with PyPy which chokes on that.
Instead it should use macros/functions PyList_GET_ITEM / PyList_SetItem

http://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev/view/head:/bzrlib/_annotator_pyx.pyx

    ctypedef struct PyListObject:
        PyObject **ob_item

...

cdef int _apply_parent_annotations(annotations, parent_annotations,
                                   matching_blocks) except -1:
    """Apply the annotations from parent_annotations into annotations.

    matching_blocks defines the ranges that match.
    """
    cdef Py_ssize_t parent_idx, lines_idx, match_len, idx
    cdef PyListObject *par_list, *ann_list
    cdef PyObject **par_temp, **ann_temp

    _check_annotations_are_lists(annotations, parent_annotations)
    par_list = <PyListObject *>parent_annotations
    ann_list = <PyListObject *>annotations
    # For NEWS and bzrlib/builtins.py, over 99% of the lines are simply copied
    # across from the parent entry. So this routine is heavily optimized for
    # that. Would be interesting if we could use memcpy() but we have to incref
    # and decref
    for parent_idx, lines_idx, match_len in matching_blocks:
        _check_match_ranges(parent_annotations, annotations,
                            parent_idx, lines_idx, match_len)
        par_temp = par_list.ob_item + parent_idx
        ann_temp = ann_list.ob_item + lines_idx
        for idx from 0 <= idx < match_len:
            Py_INCREF_ptr(par_temp[idx])
            Py_DECREF_ptr(ann_temp[idx])
            ann_temp[idx] = par_temp[idx]
    return 0

--------------------------------

PyListObject should be opaque, e.g. nothing should try to access "ob_item"
This breaks compatibility with PyPy which chokes on that.
Instead it should use macros/functions PyList_GET_ITEM / PyList_SetItem

e.g. something like

    for parent_idx, lines_idx, match_len in matching_blocks:
        _check_match_ranges(parent_annotations, annotations,
                            parent_idx, lines_idx, match_len)
        for idx from 0 <= idx < match_len:
            temp = PyList_GET_ITEM(parent_annotations, parent_idx + idx)
            ann = <object>temp
            Py_INCREF_ptr(temp)
            PyList_SetItem(annotations, lines_idx + idx, ann)

Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.