[Zope-dev] BTrees bug

Steve Alexander steve@cat-box.net
Sat, 01 Sep 2001 18:14:06 +0100


 >>> from BTrees.IOBTree import IOBucket
 >>> q=IOBucket({1:'a'})
 >>> q.keys()
[1]
 >>> q.values()
[1]
 >>> q.items()
[(1, 'a')]


I'd expect q.values() to give me ['a'].

This patch seems to fix it.

*** original BucketTemplate.c
--- new BucketTemplate.c
***************
*** 686,692 ****

     for (i=low; i <= high; i++)
       {
!       COPY_KEY_TO_OBJECT(v, self->keys[i]);
         UNLESS (v) goto err;
         if (PyList_SetItem(r, i, v) < 0) goto err;
       }
--- 686,692 ----

     for (i=low; i <= high; i++)
       {
!       COPY_VALUE_TO_OBJECT(v, self->values[i]);
         UNLESS (v) goto err;
         if (PyList_SetItem(r, i, v) < 0) goto err;
       }


cc: Collector item 2561

--
Steve Alexander
Software Engineer
Cat-Box limited