--- pymongo/bson/__init__.py.fix 2010-11-17 16:19:49.000000000 +0300 +++ pymongo/bson/__init__.py 2010-11-17 16:22:18.000000000 +0300 @@ -296,13 +296,16 @@ def _element_to_bson(key, value, check_k return "\x08" + name + "\x01" if value is False: return "\x08" + name + "\x00" - if isinstance(value, (int, long)): - # TODO this is a really ugly way to check for this... + if isinstance(value, int): if value > 2 ** 64 / 2 - 1 or value < -2 ** 64 / 2: raise OverflowError("BSON can only handle up to 8-byte ints") if value > 2 ** 32 / 2 - 1 or value < -2 ** 32 / 2: return "\x12" + name + struct.pack(" 2 ** 64 / 2 - 1 or value < -2 ** 64 / 2: + raise OverflowError("BSON can only handle up to 8-byte ints") + return "\x12" + name + struct.pack("