@@ -205,7 +205,7 @@ cdef class NSIndex(IndexBase):
205205 def __getitem__ (self , key ):
206206 assert len (key) == self .key_size
207207 data = < uint32_t * > hashindex_get(self .index, < unsigned char * > key)
208- if not data:
208+ if data == NULL :
209209 raise KeyError (key)
210210 cdef uint32_t segment = _le32toh(data[0 ])
211211 assert segment <= _MAX_VALUE, " maximum number of segments reached"
@@ -237,8 +237,8 @@ cdef class NSIndex(IndexBase):
237237 iter .index = self .index
238238 if marker:
239239 key = hashindex_get(self .index, < unsigned char * > marker)
240- if marker is None :
241- raise IndexError
240+ if key == NULL :
241+ raise KeyError ( " marker not found " )
242242 iter .key = key - self .key_size
243243 return iter
244244
@@ -296,7 +296,7 @@ cdef class ChunkIndex(IndexBase):
296296 def __getitem__ (self , key ):
297297 assert len (key) == self .key_size
298298 data = < uint32_t * > hashindex_get(self .index, < unsigned char * > key)
299- if not data:
299+ if data == NULL :
300300 raise KeyError (key)
301301 cdef uint32_t refcount = _le32toh(data[0 ])
302302 assert refcount <= _MAX_VALUE, " invalid reference count"
@@ -324,7 +324,7 @@ cdef class ChunkIndex(IndexBase):
324324 """ Increase refcount for 'key', return (refcount, size, csize)."""
325325 assert len (key) == self .key_size
326326 data = < uint32_t * > hashindex_get(self .index, < unsigned char * > key)
327- if not data:
327+ if data == NULL :
328328 raise KeyError (key)
329329 cdef uint32_t refcount = _le32toh(data[0 ])
330330 assert refcount <= _MAX_VALUE, " invalid reference count"
@@ -337,7 +337,7 @@ cdef class ChunkIndex(IndexBase):
337337 """ Decrease refcount for 'key', return (refcount, size, csize)."""
338338 assert len (key) == self .key_size
339339 data = < uint32_t * > hashindex_get(self .index, < unsigned char * > key)
340- if not data:
340+ if data == NULL :
341341 raise KeyError (key)
342342 cdef uint32_t refcount = _le32toh(data[0 ])
343343 # Never decrease a reference count of zero
@@ -354,8 +354,8 @@ cdef class ChunkIndex(IndexBase):
354354 iter .index = self .index
355355 if marker:
356356 key = hashindex_get(self .index, < unsigned char * > marker)
357- if marker is None :
358- raise IndexError
357+ if key == NULL :
358+ raise KeyError ( " marker not found " )
359359 iter .key = key - self .key_size
360360 return iter
361361
@@ -406,7 +406,7 @@ cdef class ChunkIndex(IndexBase):
406406 break
407407 our_values = < const uint32_t* > (key + self .key_size)
408408 master_values = < const uint32_t* > hashindex_get(master, key)
409- if not master_values:
409+ if master_values == NULL :
410410 raise ValueError (' stats_against: key contained in self but not in master_index.' )
411411 our_refcount = _le32toh(our_values[0 ])
412412 chunk_size = _le32toh(master_values[1 ])
@@ -434,7 +434,7 @@ cdef class ChunkIndex(IndexBase):
434434 cdef _add(self , unsigned char * key, uint32_t * data):
435435 cdef uint64_t refcount1, refcount2, result64
436436 values = < uint32_t* > hashindex_get(self .index, key)
437- if values:
437+ if values ! = NULL :
438438 refcount1 = _le32toh(values[0 ])
439439 refcount2 = _le32toh(data[0 ])
440440 assert refcount1 <= _MAX_VALUE, " invalid reference count"
0 commit comments