[Zodb-checkins] CVS: Zope/lib/python/BTrees - BucketTemplate.c:1.17.2.2

Andreas Jung andreas@zope.com
Fri, 19 Oct 2001 14:56:38 -0400


Update of /cvs-repository/Zope/lib/python/BTrees
In directory cvs.zope.org:/tmp/cvs-serv6908

Modified Files:
      Tag: Zope-2_4-branch
	BucketTemplate.c 
Log Message:

PyObject_Compare() in bucket_get() did not check for raised
exceptions (this error occured when trying to access an
OOBTree with a string with non-ascii encoding e.g. latin1.
In this case Python raises a Unicode exception that has not
been caught and not propagated to the application.


=== Zope/lib/python/BTrees/BucketTemplate.c 1.17.2.1 => 1.17.2.2 ===
 ** Returns:	object	matching object or 0/1 object
 */
+
+
 static PyObject *
 _bucket_get(Bucket *self, PyObject *keyarg, int has_key)
 {
@@ -110,6 +112,8 @@
   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);
+      if (PyErr_Occurred()) goto err;
+
       if (cmp < 0) min=i;
       else if (cmp == 0)
 	{
@@ -129,6 +133,8 @@
   PER_ACCESSED(self);
   if (has_key) return PyInt_FromLong(0);
   PyErr_SetObject(PyExc_KeyError, keyarg);
+
+err:
   return NULL;
 }