Commit 7cf7c65d authored by Jim Fulton's avatar Jim Fulton

Fixed bugs related to deleting items.

parent cef26e14
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
static char BTree_module_documentation[] = static char BTree_module_documentation[] =
"" ""
"\n$Id: BTree.c,v 1.11 1997/12/12 23:43:05 jim Exp $" "\n$Id: BTree.c,v 1.12 1997/12/31 17:18:04 jim Exp $"
; ;
#define PERSISTENT #define PERSISTENT
...@@ -643,13 +643,16 @@ _bucket_set(Bucket *self, PyObject *key, PyObject *v) ...@@ -643,13 +643,16 @@ _bucket_set(Bucket *self, PyObject *key, PyObject *v)
#endif #endif
#ifdef INTVAL #ifdef INTVAL
UNLESS(!v || PyInt_Check(v)) if(v)
{ {
PyErr_SetString(PyExc_TypeError, UNLESS(PyInt_Check(v))
"Bucket __getitem__ expected integer key"); {
return -1; PyErr_SetString(PyExc_TypeError,
"Bucket __getitem__ expected integer key");
return -1;
}
iv=PyInt_AsLong(v);
} }
iv=PyInt_AsLong(v);
#endif #endif
PER_USE_OR_RETURN(self, -1); PER_USE_OR_RETURN(self, -1);
...@@ -920,9 +923,6 @@ _BTree_set(BTree *self, PyObject *key, PyObject *value) ...@@ -920,9 +923,6 @@ _BTree_set(BTree *self, PyObject *key, PyObject *value)
#ifdef INTKEY #ifdef INTKEY
int ikey; int ikey;
#endif #endif
#ifdef INTVAL
int iv;
#endif
#ifdef INTKEY #ifdef INTKEY
UNLESS(PyInt_Check(key)) UNLESS(PyInt_Check(key))
...@@ -934,16 +934,6 @@ _BTree_set(BTree *self, PyObject *key, PyObject *value) ...@@ -934,16 +934,6 @@ _BTree_set(BTree *self, PyObject *key, PyObject *value)
ikey=PyInt_AsLong(key); ikey=PyInt_AsLong(key);
#endif #endif
#ifdef INTVAL
UNLESS(!value || PyInt_Check(value))
{
PyErr_SetString(PyExc_TypeError,
"Bucket __getitem__ expected integer key");
return -1;
}
iv=PyInt_AsLong(value);
#endif
PER_USE_OR_RETURN(self, -1); PER_USE_OR_RETURN(self, -1);
UNLESS(self->data) if(BTree_init(self) < 0) goto err; UNLESS(self->data) if(BTree_init(self) < 0) goto err;
...@@ -981,7 +971,7 @@ _BTree_set(BTree *self, PyObject *key, PyObject *value) ...@@ -981,7 +971,7 @@ _BTree_set(BTree *self, PyObject *key, PyObject *value)
{ {
d->count--; d->count--;
self->count--; self->count--;
if(! d->count) if(! d->count && self->len > 1)
{ {
self->len--; self->len--;
Py_DECREF(d->value); Py_DECREF(d->value);
...@@ -1722,7 +1712,7 @@ initBTree() ...@@ -1722,7 +1712,7 @@ initBTree()
#endif #endif
{ {
PyObject *m, *d; PyObject *m, *d;
char *rev="$Revision: 1.11 $"; char *rev="$Revision: 1.12 $";
UNLESS(PyExtensionClassCAPI=PyCObject_Import("ExtensionClass","CAPI")) UNLESS(PyExtensionClassCAPI=PyCObject_Import("ExtensionClass","CAPI"))
return; return;
...@@ -1784,6 +1774,9 @@ initBTree() ...@@ -1784,6 +1774,9 @@ initBTree()
Revision Log: Revision Log:
$Log: BTree.c,v $ $Log: BTree.c,v $
Revision 1.12 1997/12/31 17:18:04 jim
Fixed bugs related to deleting items.
Revision 1.11 1997/12/12 23:43:05 jim Revision 1.11 1997/12/12 23:43:05 jim
Added basicnew support. Added basicnew support.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment