ObjectId encodes/decodes timestamp portion as a signed integer

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 3.8
    • Affects Version/s: None
    • Component/s: BSON
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The timestamp field of an ObjectId is supposed to be an unsigned 32-bit integer but PyMongo encodes and decode it as a signed integer. This causes problems when the timestamp is larger than 31bits:

      >>> struct.pack(">i", 0x80000000)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      struct.error: 'i' format requires -2147483648 <= number <= 2147483647
      >>> struct.pack(">I", 0x80000000)
      '\x80\x00\x00\x00'
      

              Assignee:
              Prashant Mital (Inactive)
              Reporter:
              Shane Harvey
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: