Commit 218c94e6 authored by Klaus Wölfel's avatar Klaus Wölfel

wendelin: make wendelin format checksum compatible with python2 and 3

parent cb43d637
......@@ -11,5 +11,5 @@ io.seek(0)
npy_data = io.read()
io.close()
crc = struct.pack('<i', binascii.crc32(npy_data))
crc = struct.pack('<I', binascii.crc32(npy_data) & 0xffffffff)
return b''.join([MAGIC_HEADER, crc, npy_data])
......@@ -16,8 +16,8 @@ major, minor = map(ord, magic_str[-2:]) #python2
assert major == 0 and minor == 1
# verify crc32 checksum
checksum = struct.unpack('<i', data[MAGIC_LEN:HEADER_LEN])[0]
assert checksum == binascii.crc32(data[HEADER_LEN:])
checksum = struct.unpack('<I', data[MAGIC_LEN:HEADER_LEN])[0]
assert checksum == binascii.crc32(data[HEADER_LEN:]) & 0xffffffff
io = StringIO()
io.write(data[HEADER_LEN:])
io.seek(0)
......
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