Status: New
Owner: [email protected]
Labels: Type-Defect Priority-Medium
New issue 671 by [email protected]: WhichOneof doesn't work on
deserialized messages in Python
https://code.google.com/p/protobuf/issues/detail?id=671
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()
foo.name = "bob"
assert foo.IsInitialized()
assert foo.HasField("name")
assert foo.WhichOneof("test_oneof") == "name"
ser = foo.SerializeToString()
foo2 = foo_pb2.Foo()
foo2.ParseFromString(ser)
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.
foo_pb2.py attached.
Attachments:
foo_pb2.py 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:
https://code.google.com/hosting/settings
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.