diff options
| author | Scott <[email protected]> | 2022-02-02 13:47:36 -0800 |
|---|---|---|
| committer | Scott <[email protected]> | 2022-02-02 13:47:36 -0800 |
| commit | 7ff2af6fe7bffea90dc4a31c93140c189917c659 (patch) | |
| tree | 34cb138c3a572037b5bc1d1b52ad9d25a2604ccb /collect | |
| parent | 6ba90a1f30f1c0cf4df12fcd0c62181f29bc3668 (diff) | |
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.
Diffstat (limited to 'collect')
| -rw-r--r-- | collect/bst.py | 4 | ||||
| -rw-r--r-- | collect/shared_dict.py | 3 |
2 files changed, 4 insertions, 3 deletions
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): |
