[
https://issues.apache.org/jira/browse/THRIFT-5885?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18035551#comment-18035551
]
Carel commented on THRIFT-5885:
-------------------------------
I think I could reproduce this in another effort so might have a quick look if
this actually solves the problem that I see.
https://github.com/CJCombrink/thrift/pull/6/files#r2493837637 (or PR to thrift
here https://github.com/apache/thrift/pull/3227)
_The other effort_: I am trying to get the Python tests to pass for the PR
builds on Windows.
> 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
> Priority: Major
>
> 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:python}
> 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:python}
> 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)