Details
-
Improvement
-
Status: Closed
-
Major - P3
-
Resolution: Fixed
-
None
-
None
-
None
Description
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)
|