Getting started with protobuf in python I face a strange issue:
a simple message proto definition is:
syntax = "proto3";
package test;message Message {string message = 1;string sender = 2;
}
generated via protoc -I . --python_out=generated message.proto
and accessed in Python like:
from generated.message_pb2 import Message
Then I can construct a message
m = Message()
m.sender = 'foo'
m.message = 'bar'print(str(m))
but de-serializing will not return a result
s_m = m.SerializeToString()
print(s_m) # prints fine
a = m.ParseFromString(s_m)
a.foo #fails with error - no attributes deserialized