[ZCM] [ZC] 1829/ 3 Resolve "bug in IISet.minKey(maxKey)"
Collector: Zope Bugs, Features,
and Patches ...
zope-coders-admin at zope.org
Fri Jul 1 17:45:55 EDT 2005
Issue #1829 Update (Resolve) "bug in IISet.minKey(maxKey)"
Status Resolved, Zope/bug medium
To followup, visit:
http://www.zope.org/Collectors/Zope/1829
==============================================================
= Resolve - Entry #3 by tim_one on Jul 1, 2005 5:45 pm
Status: Pending => Resolved
The BTree {min,max}Key() interface docstrings were changed to clarify that an exception is raised if no key satisfies the request. Changed for ZODBs 3.2.9, 3.4.1, and 3.5.
________________________________________
= Comment - Entry #2 by tim_one on Jul 1, 2005 8:33 am
Well, in your examples there doesn't exist any key satisfying the conditions, so it's impossible to return anything (e.g., there is no value >= 15 in range(10)). An exception is appropriate. Issue 99 was an actual bug, where an exception was being raised in non-exceptional cases.
The only thing I might do in response to this is change the interface docs to be explicit about that ValueError is raised if you ask for a key that doesn't exist. It's unusual for an interface to pretend to list all possible exceptions, though. For example, you might also see TypeError if you pass a key of a silly type, and you might also see MemoryError if there's not enough RAM left to build the result.
________________________________________
= Request - Entry #1 by suvit on Jul 1, 2005 5:35 am
>>> from BTrees.IIBTree import IISet, IITreeSet
>>> iset = IISet(range(10))
>>> iset.minKey(15)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: empty bucket
>>> iset.keys(15)
[]
>>> iset.keys(5,15)
[5, 6, 7, 8, 9]
>>> iset.maxKey(5)
5
>>> iset.maxKey(-5)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: empty bucket
>>> itset = IITreeSet()
>>> itset = IITreeSet(range(10))
>>> itset.minKey(15)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: empty tree
>>> itset.minKey(10)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: empty tree
>>> itset.minKey(9)
9
>>> itset.minKey(-5)
0
but based on IKeyed Interface IISet or IITreeSet objects must return the smallest key >= min ( largest key <= max) not ValueError.
this bug is similar to http://www.zope.org/Collectors/Zope/99
==============================================================
More information about the Zope-Collector-Monitor
mailing list