Skip to content

Commit

Permalink
Fix EPDType.encode str vs bytes conflict
Browse files Browse the repository at this point in the history
Issue: EPDType.encode tried to pack a str into a 22p struct format. However, in
Python 3 onward, 22p will only accept a bytes.

Resolution: Encode the string using the ASCII charset. This guarantees that
only one byte is used per character. Non-ASCII characters will never be
generated.
  • Loading branch information
danieldulaney committed Oct 31, 2020
1 parent f5b5bb5 commit 78c5f3a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion library/inky/eeprom.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def encode(self):
self.color,
self.pcb_variant,
self.display_variant,
str(datetime.datetime.now()))
str(datetime.datetime.now()).encode("ASCII"))

def to_list(self):
"""Return a list of bytes representing the EEPROM data structure."""
Expand Down

0 comments on commit 78c5f3a

Please sign in to comment.