zopefoundation/BTrees — pull request #3 by jamadden (2014-03-06 16:38:39+00:00)
Title: Better handling of None to indicate an open range boundary in Python implementation and some C

The query methods (`keys`, `values`, `maxKey`, `minKey`) on BTrees and Sets [are documented](http://pythonhosted.org//BTrees/api.html#BTrees.Interfaces.IKeyed) to accept `None` to indicate "no boundary". Excerpt:

```python
def maxKey(key=None):
"""Return the maximum key.
If a key argument if provided and not None, return the largest key
that is less than or equal to the argument.
"""
```

This pull request does two things. First, it makes the Python implementation handle this for trees and sets, where previously the Python implementation handled it for neither, leading to exceptions like this:

```python
>>> bt = BTrees.LLBTree.LLBTreePy()
>>> bt[0] = 1
>>> bt.keys(None,None)
File "/BTrees/_base.py", line 1159, in values
return self.keys(min, max, excludemin, excludemax, 'itervalues')
File "/BTrees/_base.py", line 812, in keys
min = self._to_key(min)
File "/BTrees/_base.py", line 1423, in to_long
if not unpack("q", pack("q", v))[0] == v: #pragma NO COVER
TypeError: unsupported operand type for int(): 'NoneType'
```

Second, during the course of testing this I realized that the C implementation, although adhering to the interface for the `keys` and `values` methods, wasn't handling a None argument to `maxKey` and `minKey`, so it adds that to make it consistent all the way around.