Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
In the generated Python code, default values for enums are set as enum objects (ie, <name: value>), but thrift objects expect this value to be stored either by its name or its value. This results in a keyerror during the write method.
For example, if I have the following thrift schema
enum MyEnum {
test_a,
test_b,
test_c
}
struct MyStruct {
1: MyEnum enum_field = MyEnum.test_c
}
and then in the python code:
new_struct = MyStruct() thrift.TSerialization.serialize(new_struct)
it'd get a `keyerror` from the code generated here
oprot.writeI32(MyEnum[new_struct.enum_field].value) File "[my-path]/lib/python3.9/enum.py", line 432, in __getitem__ return cls._member_map_[name] KeyError: <MyEnum.test_c: 2>
Attachments
Issue Links
- links to