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 ...@@ -114,6 +114,11 @@ DemoStorage
BTrees 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 - (3.4.1a4) Collector 1831. The BTree ``minKey()`` and ``maxKey()`` methods
gave a misleading message if no key satisfying the constraints existed in a gave a misleading message if no key satisfying the constraints existed in a
non-empty tree. non-empty tree.
......
...@@ -752,10 +752,11 @@ Bucket_rangeSearch(Bucket *self, PyObject *args, PyObject *kw, ...@@ -752,10 +752,11 @@ Bucket_rangeSearch(Bucket *self, PyObject *args, PyObject *kw,
/* Find the low range */ /* Find the low range */
if (min != Py_None) { if (min != Py_None) {
UNLESS (rc = Bucket_findRangeEnd(self, min, 1, excludemin, low)) { rc = Bucket_findRangeEnd(self, min, 1, excludemin, low);
if (rc < 0) return -1; if (rc < 0)
return -1;
if (rc == 0)
goto empty; goto empty;
}
} }
else { else {
*low = 0; *low = 0;
...@@ -768,10 +769,11 @@ Bucket_rangeSearch(Bucket *self, PyObject *args, PyObject *kw, ...@@ -768,10 +769,11 @@ Bucket_rangeSearch(Bucket *self, PyObject *args, PyObject *kw,
/* Find the high range */ /* Find the high range */
if (max != Py_None) { if (max != Py_None) {
UNLESS (rc = Bucket_findRangeEnd(self, max, 0, excludemax, high)) { rc = Bucket_findRangeEnd(self, max, 0, excludemax, high);
if (rc < 0) return -1; if (rc < 0)
return -1;
if (rc == 0)
goto empty; goto empty;
}
} }
else { else {
*high = self->len - 1; *high = self->len - 1;
......
...@@ -1409,6 +1409,16 @@ class OOTreeSetTest(NormalSetTests): ...@@ -1409,6 +1409,16 @@ class OOTreeSetTest(NormalSetTests):
class IISetTest(ExtendedSetTests): class IISetTest(ExtendedSetTests):
def setUp(self): def setUp(self):
self.t = IISet() 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): class IFSetTest(ExtendedSetTests):
def setUp(self): def setUp(self):
self.t = IFSet() 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