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

pull/2140/head
matejcik 2 years ago committed by matejcik
parent bbf286e050
commit e0754d1609

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

@ -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),
)

Loading…
Cancel
Save