Skip to content

pdo: Fix wrongfully returned object for missing index#636

Merged
acolomb merged 2 commits intocanopen-python:masterfrom
acolomb:fix-missing-keyerror-pdo
Apr 7, 2026
Merged

pdo: Fix wrongfully returned object for missing index#636
acolomb merged 2 commits intocanopen-python:masterfrom
acolomb:fix-missing-keyerror-pdo

Conversation

@acolomb
Copy link
Copy Markdown
Member

@acolomb acolomb commented Apr 7, 2026

The fallback behavior in PdoMaps.__getitem__() tried looking up by parameter record index even when no com_offset or map_offset was defined. This caused a possibly wrong PdoMap object to be returned. For example with 0x15FF, the lookup for 0x1600 would succeed.

Add a test to make sure that an nonexistant parameter record index for 0x15FF actually does raise a KeyError. Skip the fallback lookup by parameter index if no record offsets are defined.

acolomb added 2 commits April 7, 2026 11:04
Must raise a KeyError, but currently does not.
Fixes the test failure introduced with previous commit.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@acolomb acolomb merged commit cb1622a into canopen-python:master Apr 7, 2026
4 of 5 checks passed
@acolomb acolomb deleted the fix-missing-keyerror-pdo branch April 7, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant