summaryrefslogtreecommitdiffstats
path: root/Modules/zlibmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* [3.11] gh-105967: Work around a macOS bug, limit zlib C library crc32 API ↵Miss Islington (bot)2023-12-041-5/+13
| | | | | | | | | | | | | | calls to 1gig (GH-112615) (#112725) gh-105967: Work around a macOS bug, limit zlib C library crc32 API calls to 1gig (GH-112615) Work around a macOS bug, limit zlib crc32 calls to 1GiB. Without this, `zlib.crc32` and `binascii.crc32` could produce incorrect results on multi-gigabyte inputs depending on the macOS version's Apple supplied zlib implementation. (cherry picked from commit 4eddb4c9d9452482c9af7fa9eec223d12b5a9f33) Co-authored-by: Gregory P. Smith <greg@krypto.org>
* bpo-38256: Fix binascii.crc32() when inputs are 4+GiB (GH-32000)Gregory P. Smith2022-03-201-4/+4
| | | | | | | When compiled with `USE_ZLIB_CRC32` defined (`configure` sets this on POSIX systems), `binascii.crc32(...)` failed to compute the correct value when the input data was >= 4GiB. Because the zlib crc32 API is limited to a 32-bit length. This lines it up with the `zlib.crc32(...)` implementation that doesn't have that flaw. **Performance:** This also adopts the same GIL releasing for larger inputs logic that `zlib.crc32` has, and causes the Windows build to always use zlib's crc32 instead of our slow C code as zlib is a required build dependency on Windows.
* bpo-47040: improve document of checksum functions (gh-31955)Ma Lin2022-03-191-5/+3
| | | | | | | Clarifies a versionchanged note on crc32 & adler32 docs that the workaround is only needed for Python 2 and earlier. Also cleans up an unnecessary intermediate variable in the implementation. Authored-By: Ma Lin / animalize Co-authored-by: Gregory P. Smith <greg@krypto.org>
* bpo-41735: Fix thread lock in zlib.Decompress.flush() may go wrong (GH-29587)Ma Lin2021-11-271-2/+3
| | | | | * Fix thread lock in zlib.Decompress.flush() may go wrong Getting `.unconsumed_tail` before acquiring the thread lock may mix up decompress state.
* Fix typos in the Modules directory (GH-28761)Christian Clauss2021-10-071-1/+1
|
* [codemod] Fix non-matching bracket pairs (GH-28473)Mohamad Mansour2021-09-211-1/+1
| | | | | Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-43613: Faster implementation of gzip.compress and gzip.decompress (GH-27941)Ruben Vorderman2021-09-021-3/+6
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-41486: zlib uses an UINT32_MAX sliding window for the output buffer ↵Ma Lin2021-07-051-30/+114
| | | | | | | | | | | | | | | | (GH-26143) * zlib uses an UINT32_MAX sliding window for the output buffer These funtions have an initial output buffer size parameter: - zlib.decompress(data, /, wbits=MAX_WBITS, bufsize=DEF_BUF_SIZE) - zlib.Decompress.flush([length]) If the initial size > UINT32_MAX, use an UINT32_MAX sliding window, instead of clamping to UINT32_MAX. Speed up when (the initial size == the actual size). This fixes a memory consumption and copying performance regression in earlier 3.10 beta releases if someone used an output buffer larger than 4GiB with zlib.decompress. Reviewed-by: Gregory P. Smith
* bpo-41486: Fix initial buffer size can't > UINT32_MAX in zlib module (GH-25738)Ma Lin2021-04-301-39/+44
| | | | | | | | | | | | | | | | * Fix initial buffer size can't > UINT32_MAX in zlib module After commit f9bedb630e8a0b7d94e1c7e609b20dfaa2b22231, in 64-bit build, if the initial buffer size > UINT32_MAX, ValueError will be raised. These two functions are affected: 1. zlib.decompress(data, /, wbits=MAX_WBITS, bufsize=DEF_BUF_SIZE) 2. zlib.Decompress.flush([length]) This commit re-allows the size > UINT32_MAX. * adds curly braces per PEP 7. * Renames `Buffer_*` to `OutputBuffer_*` for clarity
* bpo-43916: Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to selected types (GH-25748)Erlend Egeberg Aasland2021-04-301-10/+8
| | | | | | | | | | | | | | | | | | | | | Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to the following types: * _dbm.dbm * _gdbm.gdbm * _multibytecodec.MultibyteCodec * _sre..SRE_Scanner * _thread._localdummy * _thread.lock * _winapi.Overlapped * array.arrayiterator * functools.KeyWrapper * functools._lru_list_elem * pyexpat.xmlparser * re.Match * re.Pattern * unicodedata.UCD * zlib.Compress * zlib.Decompress
* bpo-41486: Faster bz2/lzma/zlib via new output buffering (GH-21740)Ma Lin2021-04-281-117/+168
| | | | | | | | | Faster bz2/lzma/zlib via new output buffering. Also adds .readall() function to _compression.DecompressReader class to take best advantage of this in the consume-all-output at once scenario. Often a 5-20% speedup in common scenarios due to less data copying. Contributed by Ma Lin.
* Fix thread locks in zlib module may go wrong in rare case. (#22126)Ma Lin2021-04-271-9/+10
| | | Setting `next_in` before acquiring the thread lock may mix up compress/decompress state in other threads.
* bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587)Victor Stinner2020-12-011-1/+1
| | | | | | | | | No longer use deprecated aliases to functions: * Replace PyObject_MALLOC() with PyObject_Malloc() * Replace PyObject_REALLOC() with PyObject_Realloc() * Replace PyObject_FREE() with PyObject_Free() * Replace PyObject_Del() with PyObject_Free() * Replace PyObject_DEL() with PyObject_Free()
* bpo-1635741 port zlib module to multi-phase init (GH-21995)Mohamed Koubaa2020-09-071-157/+221
| | | Port the zlib extension module to multi-phase initialization (PEP 489).
* bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)Serhiy Storchaka2020-05-261-37/+6
| | | | Only __index__ should be used to make integer conversions lossless.
* bpo-40268: Remove unused structmember.h includes (GH-19530)Victor Stinner2020-04-151-1/+1
| | | | | | If only offsetof() is needed: include stddef.h instead. When structmember.h is used, add a comment explaining that PyMemberDef is used.
* bpo-40268: Remove explicit pythread.h includes (#19529)Victor Stinner2020-04-151-1/+0
| | | | Remove explicit pythread.h includes: it is always included by Python.h.
* bpo-39968: Convert extension modules' macros of get_module_state() to inline ↵Hai Shi2020-03-161-6/+13
| | | | functions (GH-19017)
* bpo-38074: Make zlib extension module PEP-384 compatible (GH-15792)Dino Viehland2019-09-101-73/+86
| | | | Updated zlibmodule.c to be PEP 384 compliant.
* bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer2019-05-311-4/+4
| | | | | | | | | (GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
* bpo-36048: Use __index__() instead of __int__() for implicit conversion if ↵Serhiy Storchaka2019-02-251-1/+3
| | | | | | available. (GH-11952) Deprecate using the __int__() method in implicit conversions of Python numbers to C integers.
* bpo-35090: Fix potential division by zero in allocator wrappers (GH-10174)Alexey Izbyshev2018-10-281-2/+2
| | | | | | | * Fix potential division by zero in BZ2_Malloc() * Avoid division by zero in PyLzma_Malloc() * Avoid division by zero and integer overflow in PyZlib_Malloc() Reported by Svace static analyzer.
* bpo-25007: Add copy protocol support to zlib compressors and decompressors ↵Zackery Spytz2018-06-271-0/+57
| | | | (GH-7940)
* bpo-32969: Expose some missing constants in zlib and fix the doc (GH-5988)Xiang Zhang2018-03-071-3/+18
|
* bpo-31926: fix missing *_METHODDEF statements by argument clinic (#4230)Tal Einat2017-11-031-4/+0
| | | | | | | | | When a single .c file contains several functions and/or methods with the same name, a safety _METHODDEF #define statement is generated only for one of them. This fixes the bug by using the full name of the function to avoid duplicates rather than just the name.
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-18/+7
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-9566: Fix some Windows x64 compiler warnings (#2492)Segev Finer2017-07-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bpo-9566: Silence liblzma warnings * bpo-9566: Silence tcl warnings * bpo-9566: Silence tk warnings * bpo-9566: Silence tix warnings * bpo-9566: Fix some library warnings * bpo-9566: Fix msvcrtmodule.c warnings * bpo-9566: Silence _bz2 warnings * bpo-9566: Fixed some _ssl warnings * bpo-9566: Fix _msi warnings * bpo-9566: Silence _ctypes warnings * Revert "bpo-9566: Fixed some _ssl warnings" This reverts commit a639001c949ba53338a9ee047d2ec1efd2505e6f. * bpo-9566: Also consider NULL as a possible error in HANDLE_return_converter * bpo-9566: whitespace fixes
* Issue #28126: Replace Py_MEMCPY with memcpy(). Visual Studio can properly ↵Christian Heimes2016-09-131-2/+2
| | | | optimize memcpy().
* Issue #16764: Support keyword arguments to zlib.decompress(). Patch bySerhiy Storchaka2016-08-151-4/+4
| | | | Xiang Zhang.
* Issue #27130: Merge zlib 64-bit fixes from 3.5Martin Panter2016-07-231-387/+368
|\
| * Issue #27130: Fix handling of buffers exceeding UINT_MAX in “zlib” moduleMartin Panter2016-07-231-387/+368
| | | | | | | | Patch by Xiang Zhang.
* | - Issue #27332: Fixed the type of the first argument of module-level functionsSerhiy Storchaka2016-07-071-12/+12
|\ \ | |/ | | | | generated by Argument Clinic. Patch by Petr Viktorin.
| * Issue #27332: Fixed the type of the first argument of module-level functionsSerhiy Storchaka2016-07-071-12/+12
| | | | | | | | generated by Argument Clinic. Patch by Petr Viktorin.
* | Issue #26243: Only the level argument to zlib.compress() is keyword argumentSerhiy Storchaka2016-06-251-1/+2
| | | | | | | | now. The first argument is positional-only.
* | Issue #27164: Merge raw Deflate zdict support from 3.5Martin Panter2016-06-051-18/+44
|\ \ | |/
| * Issue #27164: Allow decompressing raw Deflate streams with predefined zdictMartin Panter2016-06-051-18/+44
| | | | | | | | Based on patch by Xiang Zhang.
* | Issue #5784: Merge zlib from 3.5Martin Panter2016-05-271-7/+10
|\ \ | |/
| * Issue #5784: Expand documentation and tests for zlib wbits parameterMartin Panter2016-05-271-7/+10
| | | | | | | | Based on documentation by AM Kuchling.
* | Issue #26200: Added Py_SETREF and replaced Py_XSETREF with Py_SETREFSerhiy Storchaka2016-04-101-2/+2
|\ \ | |/ | | | | in places where Py_DECREF was used.
| * Issue #26200: Added Py_SETREF and replaced Py_XSETREF with Py_SETREFSerhiy Storchaka2016-04-101-2/+2
| | | | | | | | in places where Py_DECREF was used.
* | Issue #22570: Renamed Py_SETREF to Py_XSETREF.Serhiy Storchaka2016-04-061-8/+8
|\ \ | |/
| * Issue #22570: Renamed Py_SETREF to Py_XSETREF.Serhiy Storchaka2016-04-061-8/+8
| |
* | Issue 26243: Forgot to update zlib doc strings in Argument ClinicMartin Panter2016-02-101-1/+1
| |
* | Issue #26243: zlib.compress() keyword argument support by Aviv PalivodaMartin Panter2016-02-101-9/+8
| |
* | Issue #26244: Merge zlib documentation from 3.5Martin Panter2016-02-031-3/+4
|\ \ | |/
| * Issue #26244: Clarify default zlib compression level in documentationMartin Panter2016-02-031-3/+4
| | | | | | | | Based on patch by Aviv Palivoda.
* | Issue #20440: More use of Py_SETREF.Serhiy Storchaka2015-12-271-12/+6
|\ \ | |/ | | | | | | This patch is manually crafted and contains changes that couldn't be handled automatically.
| * Issue #20440: More use of Py_SETREF.Serhiy Storchaka2015-12-271-12/+6
| | | | | | | | | | This patch is manually crafted and contains changes that couldn't be handled automatically.
* | Issue #25923: Added more const qualifiers to signatures of static and ↵Serhiy Storchaka2015-12-251-1/+1
|/ | | | private functions.
* Issue #20440: Massive replacing unsafe attribute setting code with specialSerhiy Storchaka2015-12-241-4/+2
| | | | macro Py_SETREF.