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:
909
909
# Note that proto3 field presence/optional fields are put in a
910
910
# synthetic single-item oneof by protoc, which helps us ensure we
911
911
# 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
913
913
914
914
# Empty messages can still be sent on the wire if they were
915
915
# 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