1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-17 21:22:10 +00:00

fix(python/protobuf): correctly dump messages with missing required fields

This commit is contained in:
matejcik 2022-02-18 15:44:18 +01:00 committed by matejcik
parent bbf286e050
commit e0754d1609
2 changed files with 7 additions and 2 deletions

View File

@ -0,0 +1 @@
Fixed error when printing protobuf message with a missing required field.

View File

@ -550,9 +550,13 @@ def format_message(
return repr(value)
return "{name} ({size} bytes) {content}".format(
try:
byte_size = str(pb.ByteSize()) + " bytes"
except Exception:
byte_size = "encoding failed"
return "{name} ({size}) {content}".format(
name=pb.__class__.__name__,
size=pb.ByteSize(),
size=byte_size,
content=pformat("", pb.__dict__, indent),
)