Skip to content

Commit 2e3af55

Browse files
committed
Re-raise original KeyError exception if mapping index lookup fails.
1 parent bc153d9 commit 2e3af55

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

canopen/pdo/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,12 @@ def __init__(self, com_offset: int, map_offset: int, pdo_node: PdoBase, cob_base
173173
self.maps[map_no + 1] = new_map
174174

175175
def __getitem__(self, key: int) -> PdoMap:
176-
with contextlib.suppress(KeyError):
176+
try:
177177
return self.maps[key]
178-
return self.maps[key + 1 - self.map_offset]
178+
except KeyError:
179+
with contextlib.suppress(KeyError):
180+
return self.maps[key + 1 - self.map_offset]
181+
raise
179182

180183
def __iter__(self) -> Iterator[int]:
181184
return iter(self.maps)

0 commit comments

Comments
 (0)