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

Thrift exceptions are not hashable in Python 3

    XMLWordPrintableJSON

    Details

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

      Description

      The Thrift-to-Python compiler generates `_eq` but not `hash_` for Thrift exception classes, which makes them not hashable in Python 3. Due to http://bugs.python.org/issue28603, this can lead the Python standard library to throw an error while printing tracebacks involving Thrift exceptions.

      The attached patch generates `_hash_` for Thrift exceptions. This can technically be incorrect since Thrift exceptions are mutable (compare https://issues.apache.org/jira/browse/THRIFT-162), but in practice it seems unlikely that people would mutate exception instances other than directly after creating them, and without this patch some Thrift exceptions cannot be displayed by the standard library.

        Attachments

        1. thrift-hashable-exc.patch
          0.9 kB
          Jelle Zijlstra

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Jelle Jelle Zijlstra
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m