[Zope-Checkins] CVS: Packages/BTrees - BTreeTemplate.c:1.74.8.1 BucketTemplate.c:1.54.4.2

Tim Peters tim.one at comcast.net
Tue Jul 5 12:42:04 EDT 2005


Update of /cvs-repository/Packages/BTrees
In directory cvs.zope.org:/tmp/cvs-serv26910/BTrees

Modified Files:
      Tag: Zope-2_7-branch
	BTreeTemplate.c BucketTemplate.c 
Log Message:
Collector 1831.

The BTree minKey() and maxKey() methods gave a misleading message if no
key satisfying the constraints existed in a non-empty tree.


=== Packages/BTrees/BTreeTemplate.c 1.74 => 1.74.8.1 ===
--- Packages/BTrees/BTreeTemplate.c:1.74	Fri Apr 11 12:09:58 2003
+++ Packages/BTrees/BTreeTemplate.c	Tue Jul  5 12:41:33 2005
@@ -1263,6 +1263,7 @@
   PyObject *key = 0;
   Bucket *bucket = NULL;
   int offset, rc;
+  int empty_tree = 1;
 
   UNLESS (PyArg_ParseTuple(args, "|O", &key)) return NULL;
 
@@ -1277,6 +1278,7 @@
       if ((rc = BTree_findRangeEnd(self, key, min, &bucket, &offset)) <= 0)
         {
           if (rc < 0) goto err;
+          empty_tree = 0;
           goto empty;
         }
       PER_ALLOW_DEACTIVATION(self);
@@ -1318,8 +1320,9 @@
   return key;
 
  empty:
-  PyErr_SetString(PyExc_ValueError, "empty tree");
-
+  PyErr_SetString(PyExc_ValueError,
+  		  empty_tree ? "empty tree" :
+			       "no key satisfies the conditions");
  err:
   PER_ALLOW_DEACTIVATION(self);
   PER_ACCESSED(self);


=== Packages/BTrees/BucketTemplate.c 1.54.4.1 => 1.54.4.2 ===
--- Packages/BTrees/BucketTemplate.c:1.54.4.1	Thu Apr 29 17:51:50 2004
+++ Packages/BTrees/BucketTemplate.c	Tue Jul  5 12:41:33 2005
@@ -688,6 +688,7 @@
 {
   PyObject *key=0;
   int rc, offset;
+  int empty_bucket = 1;
 
   if (args && ! PyArg_ParseTuple(args, "|O", &key)) return NULL;
 
@@ -701,6 +702,7 @@
       if ((rc = Bucket_findRangeEnd(self, key, min, &offset)) <= 0)
         {
           if (rc < 0) return NULL;
+          empty_bucket = 0;
           goto empty;
         }
     }
@@ -714,7 +716,9 @@
   return key;
 
  empty:
-  PyErr_SetString(PyExc_ValueError, "empty bucket");
+  PyErr_SetString(PyExc_ValueError,
+  		  empty_bucket ? "empty bucket" :
+  		                 "no key satisfies the conditions");
   PER_ALLOW_DEACTIVATION(self);
   PER_ACCESSED(self);
   return NULL;



More information about the Zope-Checkins mailing list