From fb2793e0b62262b44e593f4c3a8b2a1106a38ef8 Mon Sep 17 00:00:00 2001 From: Robin Lambertz Date: Wed, 25 Aug 2021 12:53:02 +0200 Subject: [PATCH] Allow parsing messages from byteslike Byteslike objects (like memoryview) do not have a decode function defined. Instead, a string may be created from them by passing them to the str constructor along with an encoding. --- src/betterproto/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/betterproto/__init__.py b/src/betterproto/__init__.py index 05b8b7c..c894aff 100644 --- a/src/betterproto/__init__.py +++ b/src/betterproto/__init__.py @@ -866,7 +866,7 @@ class Message(ABC): value = struct.unpack(fmt, value)[0] elif wire_type == WIRE_LEN_DELIM: if meta.proto_type == TYPE_STRING: - value = value.decode("utf-8") + value = str(value, "utf-8") elif meta.proto_type == TYPE_MESSAGE: cls = self._betterproto.cls_by_field[field_name]