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

UnboundLocalError for optional field in read of immutable type

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 0.10.0
    • Fix Version/s: None
    • Component/s: Python - Compiler
    • Labels:
      None

      Description

      During the read method of a structure annotated as immutable, if the value of an optional field is not read (if it is unset in the serialized structure) an UnboundLocalError is thrown when the class is instantiated.

      This is caused by storing the deserialized fields in local variables declared in nested scopes and instantiating the structure at the end of the read method: if an optional field is not set in the serialized object, the variable storing its deserialized representation (in this case, None) is never declared.

      I think this would be fixed by declaring variables for all fields at the top of the read method, initializing them to their defaults in thrift_spec.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              cjmay Chandler May
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: