[Zodb-checkins] CVS: Zope/lib/python/BTrees - BTreeTemplate.c:1.24.6.1 BucketTemplate.c:1.27.6.1 MergeTemplate.c:1.9.6.1 SetOpTemplate.c:1.12.6.1 _fsBTree.c:1.2.8.1 intkeymacros.h:1.7.50.1 objectkeymacros.h:1.2.122.1
Toby Dickenson
tdickenson@geminidataloggers.com
Mon, 11 Mar 2002 04:47:42 -0500
Update of /cvs-repository/Zope/lib/python/BTrees
In directory cvs.zope.org:/tmp/cvs-serv10488/lib/python/BTrees
Modified Files:
Tag: toby-cmp-error-branch
BTreeTemplate.c BucketTemplate.c MergeTemplate.c
SetOpTemplate.c _fsBTree.c intkeymacros.h objectkeymacros.h
Log Message:
Collector #231: BTrees ignoring errors from comparison function
=== Zope/lib/python/BTrees/BTreeTemplate.c 1.24 => 1.24.6.1 ===
for (min=0, max=self->len, i=max/2; max-min > 1; i=(min+max)/2)
{
- cmp=TEST_KEY(self->data[i].key, key);
+ TEST_KEY_SET_OR(cmp, self->data[i].key, key) return NULL;
if (cmp < 0) min=i;
else if (cmp == 0)
{
@@ -360,7 +360,7 @@
for (min=0, max=self->len, i=max/2; max-min > 1; i=(max+min)/2)
{
d=self->data+i;
- cmp=TEST_KEY(d->key, key);
+ TEST_KEY_SET_OR(cmp, d->key, key) return -1;
if (cmp < 0) min=i;
else if (cmp==0)
{
@@ -838,7 +838,7 @@
for (min=0, max=self->len, i=max/2; max-min > 1; i=(min+max)/2)
{
- cmp=TEST_KEY(self->data[i].key, key);
+ TEST_KEY_SET_OR(cmp, self->data[i].key, key) return -1;
if (cmp < 0) min=i;
else if (cmp == 0)
{
=== Zope/lib/python/BTrees/BucketTemplate.c 1.27 => 1.27.6.1 ===
for (min=0, max=self->len, i=max/2, l=max; i != l; l=i, i=(min+max)/2)
{
- cmp=TEST_KEY(self->keys[i], key);
+ TEST_KEY_SET_OR(cmp, self->keys[i], key) return NULL;
if (PyErr_Occurred()) goto err;
if (cmp < 0) min=i;
@@ -137,7 +137,8 @@
for (min=0, max=l=self->len, i=max/2; i != l; l=i, i=(min+max)/2)
{
- if ((cmp=TEST_KEY(self->keys[i], key)) < 0) min=i;
+ TEST_KEY_SET_OR(cmp, self->keys[i], key) return -1;
+ if (cmp < 0) min=i;
else if (cmp==0)
{
if (v) /* Assign value to key */
@@ -441,7 +442,7 @@
for (min=0, max=self->len, i=max/2, l=max; i != l; l=i, i=(min+max)/2)
{
- cmp=TEST_KEY(self->keys[i], key);
+ TEST_KEY_SET_OR(cmp, self->keys[i], key) return -1;
if (cmp < 0)
min=i;
else if (cmp == 0)
=== Zope/lib/python/BTrees/MergeTemplate.c 1.9 => 1.9.6.1 ===
while (i1.position >= 0 && i2.position >= 0 && i3.position >= 0)
{
- cmp12=TEST_KEY(i1.key, i2.key);
- cmp13=TEST_KEY(i1.key, i3.key);
+ TEST_KEY_SET_OR(cmp12, i1.key, i2.key) goto err;
+ TEST_KEY_SET_OR(cmp13, i1.key, i3.key) goto err;
if (cmp12==0)
{
if (cmp13==0)
@@ -142,7 +142,7 @@
}
else
{ /* Both keys changed */
- cmp23=TEST_KEY(i2.key, i3.key);
+ TEST_KEY_SET_OR(cmp23, i2.key, i3.key) goto err;
if (cmp23==0)
{ /* dualing inserts or deletes */
merge_error(i1.position, i2.position, i3.position, 4);
@@ -176,7 +176,7 @@
while (i2.position >= 0 && i3.position >= 0)
{ /* New inserts */
- cmp23=TEST_KEY(i2.key, i3.key);
+ TEST_KEY_SET_OR(cmp23, i2.key, i3.key) goto err;
if (cmp23==0)
{ /* dualing inserts */
merge_error(i1.position, i2.position, i3.position, 6);
@@ -196,7 +196,7 @@
while (i1.position >= 0 && i2.position >= 0)
{ /* deleting i3 */
- cmp12=TEST_KEY(i1.key, i2.key);
+ TEST_KEY_SET_OR(cmp12, i1.key, i2.key) goto err;
if (cmp12 > 0)
{ /* insert i2 */
if (merge_output(r, &i2, mapping) < 0) goto err;
@@ -216,7 +216,7 @@
while (i1.position >= 0 && i3.position >= 0)
{ /* deleting i2 */
- cmp13=TEST_KEY(i1.key, i3.key);
+ TEST_KEY_SET_OR(cmp13, i1.key, i3.key) goto err;
if (cmp13 > 0)
{ /* insert i3 */
if (merge_output(r, &i3, mapping) < 0) goto err;
=== Zope/lib/python/BTrees/SetOpTemplate.c 1.12 => 1.12.6.1 ===
while (i1.position >= 0 && i2.position >= 0)
{
- cmp=TEST_KEY(i1.key, i2.key);
+ TEST_KEY_SET_OR(cmp, i1.key, i2.key) return NULL;
if(cmp < 0)
{
if(c1)
=== Zope/lib/python/BTrees/_fsBTree.c 1.2 => 1.2.8.1 ===
#define KEY_TYPE char2
#define KEY_CHECK(K) (PyString_Check(K) && PyString_GET_SIZE(K)==2)
-#define TEST_KEY(K, T) ((*(K) < *(T) || (*(K) == *(T) && (K)[1] < (T)[1])) ? -1 : ((*(K) == *(T) && (K)[1] == (T)[1]) ? 0 : 1))
+#define TEST_KEY_SET_OR(V, K, T) if ( ( (V) = ((*(K) < *(T) || (*(K) == *(T) && (K)[1] < (T)[1])) ? -1 : ((*(K) == *(T) && (K)[1] == (T)[1]) ? 0 : 1)) ), 0 )
#define DECREF_KEY(KEY)
#define INCREF_KEY(k)
#define COPY_KEY(KEY, E) (*(KEY)=*(E), (KEY)[1]=(E)[1])
=== Zope/lib/python/BTrees/intkeymacros.h 1.7 => 1.7.50.1 ===
#define KEY_TYPE int
#define KEY_CHECK PyInt_Check
-#define TEST_KEY(K, T) (((K) < (T)) ? -1 : (((K) > (T)) ? 1: 0))
+#define TEST_KEY_SET_OR(V, K, T) if ( ( (V) = (((K) < (T)) ? -1 : (((K) > (T)) ? 1: 0)) ) , 0 )
#define DECREF_KEY(KEY)
#define INCREF_KEY(k)
#define COPY_KEY(KEY, E) (KEY=(E))
=== Zope/lib/python/BTrees/objectkeymacros.h 1.2 => 1.2.122.1 ===
#define KEY_TYPE PyObject *
-#define TEST_KEY(KEY, TARGET) PyObject_Compare((KEY),(TARGET))
+#define TEST_KEY_SET_OR(V, KEY, TARGET) if ( ( (V) = PyObject_Compare((KEY),(TARGET)) ), PyErr_Occurred() )
#define INCREF_KEY(k) Py_INCREF(k)
#define DECREF_KEY(KEY) Py_DECREF(KEY)
#define COPY_KEY(KEY, E) KEY=(E)