Skip to content

Commit 8029efc

Browse files
committed
pdo: handle None cob_id gracefully in __repr__
1 parent cb1622a commit 8029efc

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

canopen/pdo/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ def __init__(self, pdo_node, com_record, map_array):
229229
self._task = None
230230

231231
def __repr__(self) -> str:
232-
return f"<{type(self).__qualname__} {self.name!r} at COB-ID 0x{self.cob_id:X}>"
232+
cob = f"0x{self.cob_id:X}" if self.cob_id is not None else "Unassigned"
233+
return f"<{type(self).__qualname__} {self.name!r} at COB-ID {cob}>"
233234

234235
def __getitem_by_index(self, value):
235236
valid_values = []

0 commit comments

Comments
 (0)