Skip to content

Commit 7db9508

Browse files
committed
Allow negative integer for crc32 and adler32 calculations
1 parent 026f150 commit 7db9508

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/isal/isal_zlib.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ if ISAL_DEF_MAX_HIST_BITS > zlib.MAX_WBITS:
8686
"Please contact the developers.")
8787

8888

89-
def adler32(data, unsigned int value = 1):
89+
def adler32(data, long long value = 1):
9090
"""
9191
Computes an Adler-32 checksum of *data*. Returns the checksum as unsigned
9292
32-bit integer.
@@ -105,7 +105,7 @@ def adler32(data, unsigned int value = 1):
105105
finally:
106106
PyBuffer_Release(buffer)
107107

108-
def crc32(data, unsigned int value = 0):
108+
def crc32(data, long long value = 0):
109109
"""
110110
Computes a CRC-32 checksum of *data*. Returns the checksum as unsigned
111111
32-bit integer.

tests/test_isal.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
DATA_SIZES = [2**i for i in range(3, 20)]
3636
# 100 seeds generated with random.randint(0, 2**32-1)
3737
SEEDS_FILE = DATA_DIR / "seeds.txt"
38-
# Create seeds 0, 1 and 20 seeds from the seeds file.
39-
SEEDS = [0, 1] + [int(seed) for seed in SEEDS_FILE.read_text().splitlines()]
38+
# Create seeds -3, -20, 0, 1 and 20 seeds from the seeds file.
39+
SEEDS = [-3, -20, 0, 1] + [
40+
int(seed) for seed in SEEDS_FILE.read_text().splitlines()]
4041

4142
# Wbits for ZLIB compression, GZIP compression, and RAW compressed streams
4243
WBITS_RANGE = list(range(9, 16)) + list(range(25, 32)) + list(range(-15, -8))

0 commit comments

Comments
 (0)