Skip to content

Commit 2c34e5f

Browse files
committed
add type checks
1 parent f3fca34 commit 2c34e5f

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

Lib/test/test_zlib.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ def test_combine_no_iv_invalid_length(self):
181181
invalid_res = self.combine(chk_a, chk_b, invalid_len)
182182
self.assertNotEqual(invalid_res, checksum)
183183

184+
self.assertRaises(TypeError, self.combine, 0, 0, "len")
185+
184186
def test_combine_with_iv(self):
185187
for _ in range(self.N):
186188
a, iv_a, chk_a_with_iv = self.get_random_data(32, iv=-1)

Modules/clinic/zlibmodule.c.h

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/zlibmodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ zlib.adler32_combine -> unsigned_int
18951895
adler2: unsigned_int(bitwise=True)
18961896
Adler-32 checksum for sequence B
18971897
1898-
len2: object
1898+
len2: object(subclass_of='&PyLong_Type')
18991899
Length of sequence B
19001900
/
19011901
@@ -1909,7 +1909,7 @@ return the Adler-32 checksum of A and B concatenated.
19091909
static unsigned int
19101910
zlib_adler32_combine_impl(PyObject *module, unsigned int adler1,
19111911
unsigned int adler2, PyObject *len2)
1912-
/*[clinic end generated code: output=61842cefb16afb1b input=6fc6ff7cff42a2f2]*/
1912+
/*[clinic end generated code: output=61842cefb16afb1b input=51bb045c95130c6f]*/
19131913
{
19141914
#if defined(Z_WANT64)
19151915
z_off64_t len = convert_to_z_off_t(len2);
@@ -1980,7 +1980,7 @@ zlib.crc32_combine -> unsigned_int
19801980
crc2: unsigned_int(bitwise=True)
19811981
CRC-32 checksum for sequence B
19821982
1983-
len2: object
1983+
len2: object(subclass_of='&PyLong_Type')
19841984
Length of sequence B
19851985
/
19861986
@@ -1994,7 +1994,7 @@ return the CRC-32 checksum of A and B concatenated.
19941994
static unsigned int
19951995
zlib_crc32_combine_impl(PyObject *module, unsigned int crc1,
19961996
unsigned int crc2, PyObject *len2)
1997-
/*[clinic end generated code: output=c4def907c602e6eb input=322bf6345c88161f]*/
1997+
/*[clinic end generated code: output=c4def907c602e6eb input=9c8a065d9040dc66]*/
19981998
{
19991999
#if defined(Z_WANT64)
20002000
z_off64_t len = convert_to_z_off_t(len2);

0 commit comments

Comments
 (0)