[Zope-Checkins] CVS: Zope3/lib/python/Persistence/BTrees - BTreeTemplate.c:1.17
Tim Peters
tim.one@comcast.net
Thu, 13 Jun 2002 16:09:07 -0400
Update of /cvs-repository/Zope3/lib/python/Persistence/BTrees
In directory cvs.zope.org:/tmp/cvs-serv30486
Modified Files:
BTreeTemplate.c
Log Message:
BTree_rangeSearch(): Like its bucket counterpart, this wasn't checking
for lo > hi either, except if they happened to be in the same bucket. All
sorts of strange results followed (the range should be empty if lo > hi,
and is after this patch).
=== Zope3/lib/python/Persistence/BTrees/BTreeTemplate.c 1.16 => 1.17 ===
UNLESS (self->data && self->len) goto empty;
+ /* If f and l were both passed in, ensure f <= l. */
+ if (f && f != Py_None && l && l != Py_None)
+ {
+ int cmp;
+ KEY_TYPE first;
+ KEY_TYPE last;
+ int copied = 1;
+
+ COPY_KEY_FROM_ARG(first, f, copied);
+ UNLESS (copied) goto err;
+ COPY_KEY_FROM_ARG(last, l, copied);
+ UNLESS (copied) goto err;
+
+ TEST_KEY_SET_OR(cmp, first, last) goto err;
+ if (cmp > 0) goto empty;
+ }
+
/* Find the low range */
if (f && f != Py_None)
@@ -1381,7 +1398,7 @@
/* XXX Even though the _firstbucket attribute is read-only, a program
could probably do arbitrary damage to a the btree internals. For
example, it could call clear() on a bucket inside a BTree.
-
+
We need to decide if the convenience for inspecting BTrees is worth
the risk.
*/
@@ -1439,7 +1456,7 @@
{"update", (PyCFunction) Mapping_update, METH_O,
"update(collection)\n\n Add the items from the given collection."},
#ifdef PERSISTENT
- {"_p_resolveConflict", (PyCFunction) BTree__p_resolveConflict,
+ {"_p_resolveConflict", (PyCFunction) BTree__p_resolveConflict,
METH_VARARGS,
"_p_resolveConflict() -- Reinitialize from a newly created copy"},
{"_p_deactivate", (PyCFunction) BTree__p_deactivate, METH_NOARGS,