[
https://issues.apache.org/jira/browse/THRIFT-4531?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16415537#comment-16415537
]
ASF GitHub Bot commented on THRIFT-4531:
----------------------------------------
GitHub user margars opened a pull request:
https://github.com/apache/thrift/pull/1521
THRIFT-4531 (#1)
THRIFT-4531: Fix generated Python read() method for immutable structs with
optional members.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/margars/thrift master
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/1521.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1521
----
commit 969047b3c09af133dd3d24591baedc8ed3c52318
Author: Margar Simonyan <margar.simonyan@...>
Date: 2018-03-27T12:30:14Z
THRIFT-4531 (#1)
THRIFT-4531: Fix generated Python read() method for immutable structs with
optional members.
----
> Thrift generates wrong Python code for immutable structures with optional
> members
> ---------------------------------------------------------------------------------
>
> Key: THRIFT-4531
> URL: https://issues.apache.org/jira/browse/THRIFT-4531
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (General)
> Affects Versions: 0.11.0
> Reporter: Margar Simonyan
> Priority: Major
>
> In order to make generated Python structs hashable one needs to add
> ( python.immutable; )
> annotation. This is true for Python 3, in Python 2 technically the annotation
> is not mandatory, however leads to undesirable situation, when equal objects
> have different hash values.
> If the struct has optional members, then the generated code for read(...)
> method is wrong and results into undefined local variable error. To fix the
> issue these variables need to be added to beginning of read(...) method and
> initialized to None or default values if available.
> I have a patch for generate\t_py_generator.cc to fix the issue, but I am not
> familiar with your procedures for contributors.
>
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)