Skip to content

Commit

Permalink
Add byteorder for backward compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenediktBurger committed Oct 26, 2023
1 parent 3f1be59 commit cc6eb76
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pyleco/core/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def create_header_frame(conversation_id: Optional[bytes] = None,
elif len(message_id) != 3:
raise ValueError("Length of 'message_id' is not 3 bytes.")
if isinstance(message_type, int):
message_type = message_type.to_bytes(length=1)
message_type = message_type.to_bytes(length=1, byteorder="big")
elif len(message_type) != 1:
raise ValueError("Length of 'message_type' is not 1 bytes.")
return b"".join((conversation_id, message_id, message_type))
Expand All @@ -116,7 +116,7 @@ def interpret_header(header: bytes) -> Header:
"""
conversation_id = header[:16]
message_id = header[16:19]
message_type = int.from_bytes(header[19:20])
message_type = int.from_bytes(header[19:20], byteorder="big")
return Header(conversation_id, message_id, message_type)


Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@


cid = b"conversation_id;" # conversation_id
header = b"".join((cid, b"mid", MessageTypes.JSON.to_bytes()))
header = b"".join((cid, b"mid", MessageTypes.JSON.to_bytes(length=1, byteorder="big")))
# the result
msg = Message(b"r", b"s", conversation_id=cid, message_id=b"mid")
msg_list = ("r", "s", cid, b"", None)
Expand Down

0 comments on commit cc6eb76

Please sign in to comment.