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

UnboundLocalError for optional field in read of immutable type

Agile BoardAttach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.10.0
    • None
    • Python - Compiler
    • 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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            cjmay Chandler May

            Dates

              Created:
              Updated:

              Slack

                Issue deployment