Status: New
Labels: Type-Defect Priority-Medium

New issue 671 by WhichOneof doesn't work on deserialized messages in Python

What steps will reproduce the problem?
1. Compile the test message from the python documentation:
message Foo {
  oneof test_oneof {
     string name = 1;
     int32 serial_number = 2;

2. Run the script:
import foo_pb2

foo = foo_pb2.Foo() = "bob"

assert foo.IsInitialized()
assert foo.HasField("name")
assert foo.WhichOneof("test_oneof") == "name"

ser = foo.SerializeToString()

foo2 = foo_pb2.Foo()

assert foo2.IsInitialized()
assert foo2.HasField("name")

#This will fail
assert foo2.WhichOneof("test_oneof") == "name"

What is the expected output? What do you see instead?
foo2.WhichOneof("test_oneof") should return "name", it always returns None.

What version of the product are you using? On what operating system?
Python 2.7.6 on Ubuntu 14.04
python protobuf 2.6.0 (installed via pip from pypi)
protoc version libprotoc 2.6.0, compiled locally

Please provide any additional information below. attached.

Attachments:  2.5 KB
        foo.proto  94 bytes

You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:

You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
For more options, visit

Reply via email to