python 2.6 compatibility

This commit is contained in:
Adrian Sampson 2013-09-16 18:35:31 -07:00
parent a5422eeaf7
commit 3229c59b60

View file

@ -472,10 +472,13 @@ class Item(LibModel):
for key in ITEM_KEYS_META:
value = getattr(f, key)
if isinstance(value, (int, long)) and value.bit_length() > 63:
if isinstance(value, (int, long)):
# Filter values wider than 64 bits (in signed
# representation). SQLite cannot store them.
value = 0
# py26: Post transition, we can use:
# value.bit_length() > 63
if abs(value) >= 2 ** 63:
value = 0
setattr(self, key, value)
# Database's mtime should now reflect the on-disk value.