Rev 2484: Explicitly calling Py_INCREF makes things happier again. in http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/dirstate_pyrex
John Arbash Meinel
john at arbash-meinel.com
Fri May 4 05:38:05 BST 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/dirstate_pyrex
------------------------------------------------------------
revno: 2484
revision-id: john at arbash-meinel.com-20070504043751-5unx865kqw9scyyu
parent: john at arbash-meinel.com-20070504041902-r5vxd4xpkduhbd0b
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate_pyrex
timestamp: Thu 2007-05-03 23:37:51 -0500
message:
Explicitly calling Py_INCREF makes things happier again.
modified:
bzrlib/compiled/dirstate_helpers.pyx dirstate_helpers.pyx-20070503201057-u425eni465q4idwn-3
-------------- next part --------------
=== modified file 'bzrlib/compiled/dirstate_helpers.pyx'
--- a/bzrlib/compiled/dirstate_helpers.pyx 2007-05-04 04:19:02 +0000
+++ b/bzrlib/compiled/dirstate_helpers.pyx 2007-05-04 04:37:51 +0000
@@ -28,6 +28,11 @@
int PyDict_SetItem(object p, object key, object val) except -1
object PyList_GetItem(object lst, int index)
object PyTuple_GetItem(object tpl, int index)
+ int PyList_CheckExact(object)
+ int PyTuple_CheckExact(object)
+
+ void Py_INCREF(object)
+ void Py_DECREF(object)
cdef object _split_from_path(object cache, object path):
@@ -67,19 +72,31 @@
cdef int _mid
cdef object dirname_split
cdef object cur_split
+ cdef object block
if hi is None:
_hi = len(dirblocks)
else:
_hi = hi
+ if not PyList_CheckExact(dirblocks):
+ raise TypeError('you must pass a python list for dirblocks')
_lo = lo
dirname_split = dirname.split('/')
while _lo < _hi:
_mid = (_lo+_hi)/2
# Grab the dirname for the current dirblock
- #cur = PyTuple_GetItem(PyList_GetItem(dirblocks, _mid), 0)
- cur = dirblocks[_mid][0]
+ # block = dirblocks[_mid]
+ block = PyList_GetItem(dirblocks, _mid)
+ Py_INCREF(block) # PyList_GetItem doesn't increment the ref counter,
+ # but pyrex assumes objects have proper reference
+ # counts. We were trying to have block not care
+ # but that doesn't seem possible
+ if not PyTuple_CheckExact(block):
+ raise TypeError('We expect to have a list of tuples')
+ # cur = block[0]
+ cur = PyTuple_GetItem(block, 0)
+ Py_INCREF(cur)
cur_split = cur.split('/')
if cur_split < dirname_split: _lo = _mid+1
else: _hi = _mid
More information about the bazaar-commits
mailing list