Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4531

Thrift generates wrong Python code for immutable structures with optional members

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.11.0
    • 0.12.0
    • Compiler (General)
    • None

    Description

      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.

       

       

       

      Attachments

        Issue Links

          Activity

            People

              dcelasun Duru Can Celasun
              Margar Margar Simonyan
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: