File tree 2 files changed +5
-2
lines changed
2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -917,7 +917,7 @@ def dump(self, stream: BinaryIO) -> None:
917
917
# Note that proto3 field presence/optional fields are put in a
918
918
# synthetic single-item oneof by protoc, which helps us ensure we
919
919
# send the value even if the value is the default zero value.
920
- selected_in_group = bool (meta .group )
920
+ selected_in_group = bool (meta .group ) or meta . optional
921
921
922
922
# Empty messages can still be sent on the wire if they were
923
923
# set (or received empty).
Original file line number Diff line number Diff line change @@ -385,7 +385,10 @@ def is_oneof(proto_field_obj: FieldDescriptorProto) -> bool:
385
385
us to tell whether it was set, via the which_one_of interface.
386
386
"""
387
387
388
- return which_one_of (proto_field_obj , "oneof_index" )[0 ] == "oneof_index"
388
+ return (
389
+ not proto_field_obj .proto3_optional
390
+ and which_one_of (proto_field_obj , "oneof_index" )[0 ] == "oneof_index"
391
+ )
389
392
390
393
391
394
@dataclass
You can’t perform that action at this time.
0 commit comments