From 7ff2af6fe7bffea90dc4a31c93140c189917c659 Mon Sep 17 00:00:00 2001 From: Scott Date: Wed, 2 Feb 2022 13:47:36 -0800 Subject: Let's be explicit with asserts; there was a bug in histogram caused by assert foo when foo was an int with valid valid 0. --- collect/bst.py | 4 ++-- collect/shared_dict.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'collect') diff --git a/collect/bst.py b/collect/bst.py index 9d65259..8602ce6 100644 --- a/collect/bst.py +++ b/collect/bst.py @@ -520,12 +520,12 @@ class BinarySearchTree(object): return x path = self.parent_path(node) - assert path[-1] + assert path[-1] is not None assert path[-1] == node path = path[:-1] path.reverse() for ancestor in path: - assert ancestor + assert ancestor is not None if node != ancestor.right: return ancestor node = ancestor diff --git a/collect/shared_dict.py b/collect/shared_dict.py index 7c84c14..ac390bc 100644 --- a/collect/shared_dict.py +++ b/collect/shared_dict.py @@ -74,6 +74,7 @@ class SharedDict(object): super().__init__() self.name = name self._serializer = PickleSerializer() + assert size_bytes is None or size_bytes > 0 self.shared_memory = self._get_or_create_memory_block(name, size_bytes) self._ensure_memory_initialization() self.lock = RLock() @@ -89,7 +90,7 @@ class SharedDict(object): try: return shared_memory.SharedMemory(name=name) except FileNotFoundError: - assert size_bytes + assert size_bytes is not None return shared_memory.SharedMemory(name=name, create=True, size=size_bytes) def _ensure_memory_initialization(self): -- cgit v1.3