Commit 679a64b6 authored by Jason Madden's avatar Jason Madden

Detect the bitness of the current process in order to better match the C...

Detect the bitness of the current process in order to better match the C TimeStamp hashcode. Fixes zopefoundation/persistent#21
parent 663497de
......@@ -13,12 +13,21 @@
##############################################################################
__all__ = ('TimeStamp',)
from ctypes import c_int64
import datetime
import math
import struct
import sys
# We need to use a native ctype to get the overflow behaviour in the
# __hash__ function to match the C implementation. However, which one
# to use depends on whether we were built 64-bit or 32-bit.
if sys.maxsize > 2**32:
# the `platform` docs say this is the most reliable way to
# detect 64-bit
from ctypes import c_int64 as c_long
else:
from ctypes import c_long
_RAWTYPE = bytes
def _makeOctets(s):
......@@ -158,7 +167,7 @@ class pyTimeStamp(object):
# Make sure to overflow and wraparound just
# like the C code does.
x = c_int64(x).value
x = c_long(x).value
if x == -1: #pragma: no cover
# The C version has this condition, but it's not clear
# why; it's also not immediately obvious what bytestring
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment