File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -909,7 +909,7 @@ def dump(self, stream: BinaryIO) -> None:
909909 # Note that proto3 field presence/optional fields are put in a
910910 # synthetic single-item oneof by protoc, which helps us ensure we
911911 # send the value even if the value is the default zero value.
912- selected_in_group = bool (meta .group )
912+ selected_in_group = bool (meta .group ) or meta . optional
913913
914914 # Empty messages can still be sent on the wire if they were
915915 # 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:
385385 us to tell whether it was set, via the which_one_of interface.
386386 """
387387
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+ )
389392
390393
391394@dataclass
You can’t perform that action at this time.
0 commit comments