mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #25626: Change zlib to accept Py_ssize_t and cap to UINT_MAX
The underlying zlib library stores sizes in “unsigned int”. The corresponding Python parameters are all sizes of buffers filled in by zlib, so it is okay to reduce higher values to the UINT_MAX internal cap. OverflowError is still raised for sizes that do not fit in Py_ssize_t. Sizes are now limited to Py_ssize_t rather than unsigned long, because Python byte strings cannot be larger than Py_ssize_t. Previously this could result in a SystemError on 32-bit platforms. This resolves a regression in the gzip module when reading more than UINT_MAX or LONG_MAX bytes in one call, introduced by revision 62723172412c.
This commit is contained in:
parent
d13cade381
commit
e99e97762c
7 changed files with 120 additions and 47 deletions
|
@ -1608,12 +1608,15 @@ class _MemoryWatchdog:
|
|||
def bigmemtest(size, memuse, dry_run=True):
|
||||
"""Decorator for bigmem tests.
|
||||
|
||||
'minsize' is the minimum useful size for the test (in arbitrary,
|
||||
test-interpreted units.) 'memuse' is the number of 'bytes per size' for
|
||||
the test, or a good estimate of it.
|
||||
'size' is a requested size for the test (in arbitrary, test-interpreted
|
||||
units.) 'memuse' is the number of bytes per unit for the test, or a good
|
||||
estimate of it. For example, a test that needs two byte buffers, of 4 GiB
|
||||
each, could be decorated with @bigmemtest(size=_4G, memuse=2).
|
||||
|
||||
if 'dry_run' is False, it means the test doesn't support dummy runs
|
||||
when -M is not specified.
|
||||
The 'size' argument is normally passed to the decorated test method as an
|
||||
extra argument. If 'dry_run' is true, the value passed to the test method
|
||||
may be less than the requested value. If 'dry_run' is false, it means the
|
||||
test doesn't support dummy runs when -M is not specified.
|
||||
"""
|
||||
def decorator(f):
|
||||
def wrapper(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue