Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1635

ObjectId encodes/decodes timestamp portion as a signed integer

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.8
    • Affects Version/s: None
    • Component/s: BSON
    • Labels:
      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 Prashant Mital (Inactive)
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: