Skip to content

Commit a5eb9dd

Browse files
jared mauchjared mauch
authored andcommitted
Fix KeyError in HyperDatabase when checking parentID in articleIndex
Add __contains__ method to DumbBTree class to properly handle 'in' operator checks. Previously, when parentID was 0 (or any value not in the index), Python would fall back to __getitem__ which raised KeyError. Now __contains__ returns False for missing keys instead of raising an exception.
1 parent c4070cc commit a5eb9dd

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Mailman/Archiver/HyperDatabase.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ def __next__(self):
148148
def has_key(self, key):
149149
return key in self.dict
150150

151+
def __contains__(self, key):
152+
return key in self.dict
153+
151154
def set_location(self, loc):
152155
index = 0
153156
self.__sort()

0 commit comments

Comments
 (0)