[ https://issues.apache.org/jira/browse/THRIFT-4531?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16415444#comment-16415444 ]
ASF GitHub Bot commented on THRIFT-4531: ---------------------------------------- GitHub user margars opened a pull request: https://github.com/apache/thrift/pull/1520 THRIFT-4531 I am not familiar with your rules for contributions. This issue is described in JIRA THRIFT-4531. 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/1520.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 #1520 ---- commit d682b13e5e7672702e53f1e696263ef5293d8d37 Author: Margar Simonyan <margar.simonyan@...> Date: 2018-03-27T11:22:10Z Update t_py_generator.cc Fix the generated read() method for immutable structures with optional members. commit 14a4c46c480ae041bb51397cefc9be575f17f79a Author: Margar Simonyan <margar.simonyan@...> Date: 2018-03-27T11:26:51Z Merge pull request #1 from margars/THRIFT-4531 Update t_py_generator.cc commit 29289f4d8c88fee636b779a94aeae48bf81671b0 Author: Margar Simonyan <margar.simonyan@...> Date: 2018-03-27T11:28:11Z Revert "Update t_py_generator.cc" commit 56dc4f04c20a9601063deec75630ff4212937a46 Author: Margar Simonyan <margar.simonyan@...> Date: 2018-03-27T11:28:35Z Merge pull request #2 from margars/revert-1-THRIFT-4531 Revert "Update t_py_generator.cc" ---- > 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)