mirror of
https://github.com/python/cpython.git
synced 2024-11-24 10:24:35 +08:00
Portable way of producing unsigned 32-bit hex output to print the
CRCs.
This commit is contained in:
parent
baf29638da
commit
a6fa0e6f2e
@ -12,8 +12,10 @@ buf = file.read() * 8
|
||||
file.close()
|
||||
|
||||
# test the checksums (hex so the test doesn't break on 64-bit machines)
|
||||
print hex(zlib.crc32('penguin')), hex(zlib.crc32('penguin', 1))
|
||||
print hex(zlib.adler32('penguin')), hex(zlib.adler32('penguin', 1))
|
||||
def fix(x):
|
||||
return "0x%x" % (x & 0xffffffffL)
|
||||
print fix(zlib.crc32('penguin')), fix(zlib.crc32('penguin', 1))
|
||||
print fix(zlib.adler32('penguin')), fix(zlib.adler32('penguin', 1))
|
||||
|
||||
# make sure we generate some expected errors
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user