Commit e75e2c06 authored by Tim Peters's avatar Tim Peters

Collector 1843: IISet.keys: bad exception handling.

Bucket_rangeSearch():  De-obfuscated the calls to
Bucket_findRangeEnd(), so that they stop ignoring
the latter's error returns (a mind-bending combination
of embedded assignment nested in an UNLESS macro,
seemingly copy+paste'd so that the error occurred twice).
parent ad2fef94
......@@ -114,6 +114,11 @@ DemoStorage
BTrees
------
- (3.4.1a6) Collector 1843. When a non-integer was passed to a method like
``keys()`` of a Bucket or Set with integer keys, an internal error code
was overlooked, leading to everything from "delayed errors" to segfaults.
Such cases raise TypeError now, as intended.
- (3.4.1a4) Collector 1831. The BTree ``minKey()`` and ``maxKey()`` methods
gave a misleading message if no key satisfying the constraints existed in a
non-empty tree.
......
......@@ -752,11 +752,12 @@ Bucket_rangeSearch(Bucket *self, PyObject *args, PyObject *kw,
/* Find the low range */
if (min != Py_None) {
UNLESS (rc = Bucket_findRangeEnd(self, min, 1, excludemin, low)) {
if (rc < 0) return -1;
rc = Bucket_findRangeEnd(self, min, 1, excludemin, low);
if (rc < 0)
return -1;
if (rc == 0)
goto empty;
}
}
else {
*low = 0;
if (excludemin) {
......@@ -768,11 +769,12 @@ Bucket_rangeSearch(Bucket *self, PyObject *args, PyObject *kw,
/* Find the high range */
if (max != Py_None) {
UNLESS (rc = Bucket_findRangeEnd(self, max, 0, excludemax, high)) {
if (rc < 0) return -1;
rc = Bucket_findRangeEnd(self, max, 0, excludemax, high);
if (rc < 0)
return -1;
if (rc == 0)
goto empty;
}
}
else {
*high = self->len - 1;
if (excludemax) {
......
......@@ -1409,6 +1409,16 @@ class OOTreeSetTest(NormalSetTests):
class IISetTest(ExtendedSetTests):
def setUp(self):
self.t = IISet()
# Collector 1843. Error returns were effectively ignored in
# Bucket_rangeSearch(), leading to "delayed" errors, or worse.
def testNonIntKeyRaises(self):
self.t.insert(1)
# This one used to fail to raise the TypeError when it occurred.
self.assertRaises(TypeError, self.t.keys, "")
# This one used to segfault.
self.assertRaises(TypeError, self.t.keys, 0, "")
class IFSetTest(ExtendedSetTests):
def setUp(self):
self.t = IFSet()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment