From 6835748bbff3f4bdfeb74c9145a21ab4e5433123 Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Wed, 7 Aug 2019 10:58:03 +0200 Subject: [PATCH] core/protobuf: fix 5b6fa113 --- core/src/protobuf.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/src/protobuf.py b/core/src/protobuf.py index 65f2c290b8..74e91603d5 100644 --- a/core/src/protobuf.py +++ b/core/src/protobuf.py @@ -6,7 +6,7 @@ bytes, string, embedded message and repeated fields. from micropython import const if False: - from typing import Any, Dict, Iterable, List, Type, TypeVar, Union + from typing import Any, Dict, Iterable, List, Optional, Type, TypeVar, Union from typing_extensions import Protocol class AsyncReader(Protocol): @@ -278,10 +278,7 @@ async def dump_message( repvalue[0] = fvalue fvalue = repvalue - if isinstance(ftype, type) and issubclass(ftype, MessageType): - ffields = ftype.get_fields() - else: - ffields = None + ffields = None # type: Optional[Dict] for svalue in fvalue: await dump_uvarint(writer, fkey) @@ -313,6 +310,8 @@ async def dump_message( await writer.awrite(svalue) elif issubclass(ftype, MessageType): + if ffields is None: + ffields = ftype.get_fields() await dump_uvarint(writer, count_message(svalue, ffields)) await dump_message(writer, svalue, ffields)