Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-1561

gremiln-python GraphSONWriter doesn't properly serialize long in Python 3.5

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.2.3
    • Fix Version/s: 3.2.4
    • Component/s: python
    • Labels:
      None
    • Environment:
      Python 3.5

      Description

      Because long doesn't exist in Python 3, we created a simple wrapper that inherits from int to fill the void. After the last changes to the gremlin-python graphson module, this inheritance causes our longs to be serialized as Int32. For example:

      from gremlin_python.statics import long
      from gremlin_python.structure.io.graphson import GraphSONWriter
      
      writer = GraphSONWriter()
      
      writer.toDict(1)
      {'@type': 'g:Int32', '@value': 1}
      
      writer.toDict(long(1))
      {'@type': 'g:Int32', '@value': 1}
      

      This should be an easy fix. As far as I can see there are two main approaches:
      1. Combine the Int64IO and Int32IO classes and perform an instance check for long in the dictify() method; or,

      2. Implement a long type that doesn't inherit from int. Here we would probably want to define a variety of methods so our long emulates Python's numeric object.

      Does anyone have an opinion on a preferred approach? I would probably go with the first approach, but either could work.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                davebshow David M. Brown
                Reporter:
                davebshow David M. Brown
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: