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

Work around pure python integer overflow bug in python 2.5 shipped with OSX Mountain Lion

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.3
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Note: this is not a PyMongo bug but it currently affects some validation code in various parts of PyMongo.

      The interpreter bug can be seen here (python 2.6 is correct, 2.5 is incorrect):

      devtop:bson behackett$ python2.6
      Python 2.6.7 (r267:88850, Jun 20 2012, 16:23:38) 
      [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
      Type "help", "copyright", "credits" or "license" for more information.
      >>> 2 ** 32
      4294967296
      >>> ^D
      devtop:bson behackett$ python2.5
      Python 2.5.6 (r256:88840, Jun 20 2012, 16:23:17) 
      [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
      Type "help", "copyright", "credits" or "license" for more information.
      >>> 2 ** 32
      0
      

      This breaks some validation code in PyMongo that unnecessarily calculates upper bounds of integer parameters. You can see the problem running PyMongo's unittests:

      ======================================================================
      ERROR: test_exceptions (test.test_timestamp.TestTimestamp)
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/Users/behackett/work/mongo-python-driver/test/test_timestamp.py", line 65, in test_exceptions
          self.assertTrue(Timestamp(0, 0))
        File "/Users/behackett/work/mongo-python-driver/bson/timestamp.py", line 58, in __init__
          raise ValueError("time must be contained in [0, 2**32)")
      ValueError: time must be contained in [0, 2**32)
      

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            bernie@mongodb.com Bernie Hackett
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: