diff --git a/pylgbst/messages.py b/pylgbst/messages.py index 09e5d68..7236a36 100644 --- a/pylgbst/messages.py +++ b/pylgbst/messages.py @@ -58,7 +58,7 @@ class UpstreamMsg(Message): assert hub_id == 0 msg_type = msg._byte() assert cls.TYPE == msg_type, "Message type does not match: %x!=%x" % (cls.TYPE, msg_type) - assert isinstance(msg.payload, bytes) + assert isinstance(msg.payload, (bytes, bytearray)) return msg def __shift(self, vtype, vlen): diff --git a/pylgbst/utilities.py b/pylgbst/utilities.py index e479ea3..faf8a4d 100644 --- a/pylgbst/utilities.py +++ b/pylgbst/utilities.py @@ -30,7 +30,7 @@ def usint(seq, index): def str2hex(data): # we need it for python 2+3 compatibility # if sys.version_info[0] == 3: # data = bytes(data, 'ascii') - if not isinstance(data, bytes): + if not isinstance(data, (bytes, bytearray)): data = bytes(data, 'ascii') hexed = binascii.hexlify(data) return hexed