Adrian Stachlewski created THRIFT-5885: ------------------------------------------
Summary: TBinaryProtocolAccelerated incorrectly deserializes IntEnum to None Key: THRIFT-5885 URL: https://issues.apache.org/jira/browse/THRIFT-5885 Project: Thrift Issue Type: Bug Components: Python - Compiler, Python - Library Affects Versions: 0.22.0 Environment: thrift==0.22.0 Reporter: Adrian Stachlewski When using {{{}TBinaryProtocolAccelerated{}}}, {{IntEnum}} fields are incorrectly deserialized to {{{}None{}}}. This issue occurs when the {{read}} function is executed via {{{}_fast_decode{}}}. In this path, the custom deserialization logic {{CustomEnum(iprot.readI32())}} is skipped. Instead, an integer value ({{{}i32{}}}) is directly passed to {{{}__setattr__{}}}, where the value is resolved using: {code:java} Operation.__members__.get(value) {code} However, __members__ maps enum names (not values) to enum members, which results in the call returning None. This leads to the enum field being set to None instead of the expected enum instance. A minimal and effective fix could be to update the __setattr__ method logic to: {code:java} if name == "enum_field": super().__setattr__(name, value if hasattr(value, 'value') or value is None else Operation(value)) {code} This would ensure that the enum value is correctly reconstructed from its integer representation during deserialization. -- This message was sent by Atlassian Jira (v8.20.10#820010)