Skip to content

Commit c90b878

Browse files
committed
Skip the fallback lookup by parameter index without record offsets.
Fixes the test failure introduced with previous commit.
1 parent 0c980a6 commit c90b878

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

canopen/pdo/base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,12 @@ def __getitem__(self, key: int) -> PdoMap:
175175
try:
176176
return self.maps[key]
177177
except KeyError:
178-
with contextlib.suppress(KeyError):
179-
return self.maps[key + 1 - self.map_offset]
180-
with contextlib.suppress(KeyError):
181-
return self.maps[key + 1 - self.com_offset]
178+
if self.map_offset:
179+
with contextlib.suppress(KeyError):
180+
return self.maps[key + 1 - self.map_offset]
181+
if self.com_offset:
182+
with contextlib.suppress(KeyError):
183+
return self.maps[key + 1 - self.com_offset]
182184
raise
183185

184186
def __iter__(self) -> Iterator[int]:

0 commit comments

Comments
 (0)