commit fa1234ddfd3db1d951b61ff2f45a829e5f1c4618 Author: Isis Lovecruft isis@torproject.org Date: Fri Nov 15 13:47:38 2013 +0000
Change asserts to validations in FilteredBridgeSplitter.insert().
The asserts will be stripped if Python is run with -O2, thus they are not the best idea for production code. --- lib/bridgedb/Bridges.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/lib/bridgedb/Bridges.py b/lib/bridgedb/Bridges.py index 036df88..7e24dbe 100644 --- a/lib/bridgedb/Bridges.py +++ b/lib/bridgedb/Bridges.py @@ -1057,12 +1057,18 @@ class FilteredBridgeSplitter(BridgeHolder): :param populate_from: A group of :class:`Bridge`s. If given, the newly added subring will be populated with these bridges. """ - assert isinstance(ring, BridgeHolder) - assert ringname not in self.filterRings.keys() - logging.debug("Adding subring '%s' to %s." + if not isinstance(subring, BridgeHolder): + logging.fatal("Can't add '%s' to %s because '%s' isn't a hashring." + % (ringname, self.__class__, ringname)) + return False + if ringname in self.filterRings.keys(): + logging.fatal("Hashring %s already has a subring named '%s'!" + % (self.__class__, ringname)) + return False + + logging.debug("Adding subring '%s' to hashring %s..." % (ringname, self.__class__))
- #TODO: drop LRU ring if len(self.filterRings) > self.max_cached_rings self.filterRings[ringname] = (filterFn, subring)