- 
                Notifications
    You must be signed in to change notification settings 
- Fork 15.9k
Closed
Labels
Description
The documentation for enum says:
For example, you can access the values in the three following ways for the following enum in a proto:
enum SomeEnum {
    VALUE_A = 0;
    VALUE_B = 5;
    VALUE_C = 1234;
}value-a = myproto_pb2.SomeEnum.VALUE_A
# or
myproto_pb2.VALUE_A
# or
myproto_pb2.SomeEnum.Value('VALUE_A')But value-a = myproto_pb2.SomeEnum.VALUE_A fails.
What version of protobuf and what language are you using?
Version: v3.7.1/v3.6.1
Language: Python
What operating system (Linux, Windows, ...) and version?
Xubuntu 18.04
What runtime / compiler are you using (e.g., python version or gcc version)
gcc
What did you do?
- Save the proto definition from the documentation to a file name myproto.proto.
- Generate the python code:
./protoc --python_out=. --proto_path=. myproto.proto 
- Attempt to access the value in the ways the documentation demonstrates.
python -c "import myproto_pb2; print(myproto_pb2.SomeEnum.Value('VALUE_A')); print(myproto_pb2.VALUE_A); print(myproto_pb2.SomeEnum.VALUE_A);"
What did you expect to see
0
0
0
What did you see instead?
0
0
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'EnumTypeWrapper' object has no attribute 'VALUE_A'
pingzh, eatingw233, agentydragon, Hazhzeng and yesyu