~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/compiled/dirstate_helpers.pyx

  • Committer: John Arbash Meinel
  • Date: 2007-05-04 04:37:51 UTC
  • mto: This revision was merged to the branch mainline in revision 2643.
  • Revision ID: john@arbash-meinel.com-20070504043751-5unx865kqw9scyyu
Explicitly calling Py_INCREF makes things happier again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    int PyDict_SetItem(object p, object key, object val) except -1
29
29
    object PyList_GetItem(object lst, int index)
30
30
    object PyTuple_GetItem(object tpl, int index)
 
31
    int PyList_CheckExact(object)
 
32
    int PyTuple_CheckExact(object)
 
33
 
 
34
    void Py_INCREF(object)
 
35
    void Py_DECREF(object)
31
36
 
32
37
 
33
38
cdef object _split_from_path(object cache, object path):
67
72
    cdef int _mid
68
73
    cdef object dirname_split
69
74
    cdef object cur_split
 
75
    cdef object block
70
76
 
71
77
    if hi is None:
72
78
        _hi = len(dirblocks)
73
79
    else:
74
80
        _hi = hi
75
81
 
 
82
    if not PyList_CheckExact(dirblocks):
 
83
        raise TypeError('you must pass a python list for dirblocks')
76
84
    _lo = lo
77
85
    dirname_split = dirname.split('/')
78
86
    while _lo < _hi:
79
87
        _mid = (_lo+_hi)/2
80
88
        # Grab the dirname for the current dirblock
81
 
        #cur = PyTuple_GetItem(PyList_GetItem(dirblocks, _mid), 0)
82
 
        cur = dirblocks[_mid][0]
 
89
        # block = dirblocks[_mid]
 
90
        block = PyList_GetItem(dirblocks, _mid)
 
91
        Py_INCREF(block) # PyList_GetItem doesn't increment the ref counter,
 
92
                         # but pyrex assumes objects have proper reference
 
93
                         # counts. We were trying to have block not care
 
94
                         # but that doesn't seem possible
 
95
        if not PyTuple_CheckExact(block):
 
96
            raise TypeError('We expect to have a list of tuples')
 
97
        # cur = block[0]
 
98
        cur = PyTuple_GetItem(block, 0)
 
99
        Py_INCREF(cur)
83
100
        cur_split = cur.split('/')
84
101
        if cur_split < dirname_split: _lo = _mid+1
85
102
        else: _hi = _mid