summaryrefslogtreecommitdiffstats
path: root/Modules/zlibmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-108220: Internal header files require Py_BUILD_CORE to be defined (#108221)Victor Stinner2023-08-211-0/+4
| | | | | | | | | * pycore_intrinsics.h does nothing if included twice (add #ifndef and #define). * Update Tools/cases_generator/generate_cases.py to generate the Py_BUILD_CORE test. * _bz2, _lzma, _opcode and zlib extensions now define the Py_BUILD_CORE_MODULE macro to use internal headers (pycore_code.h, pycore_intrinsics.h and pycore_blocks_output_buffer.h).
* gh-107279 Add `<stddef.h>` to `Modules/zlibmodule.c` to fix failing builds ↵shailshouryya2023-07-271-0/+1
| | | | (#107280)
* gh-106869: Use new PyMemberDef constant names (#106871)Victor Stinner2023-07-251-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove '#include "structmember.h"'. * If needed, add <stddef.h> to get offsetof() function. * Update Parser/asdl_c.py to regenerate Python/Python-ast.c. * Replace: * T_SHORT => Py_T_SHORT * T_INT => Py_T_INT * T_LONG => Py_T_LONG * T_FLOAT => Py_T_FLOAT * T_DOUBLE => Py_T_DOUBLE * T_STRING => Py_T_STRING * T_OBJECT => _Py_T_OBJECT * T_CHAR => Py_T_CHAR * T_BYTE => Py_T_BYTE * T_UBYTE => Py_T_UBYTE * T_USHORT => Py_T_USHORT * T_UINT => Py_T_UINT * T_ULONG => Py_T_ULONG * T_STRING_INPLACE => Py_T_STRING_INPLACE * T_BOOL => Py_T_BOOL * T_OBJECT_EX => Py_T_OBJECT_EX * T_LONGLONG => Py_T_LONGLONG * T_ULONGLONG => Py_T_ULONGLONG * T_PYSSIZET => Py_T_PYSSIZET * T_NONE => _Py_T_NONE * READONLY => Py_READONLY * PY_AUDIT_READ => Py_AUDIT_READ * READ_RESTRICTED => Py_AUDIT_READ * PY_WRITE_RESTRICTED => _Py_WRITE_RESTRICTED * RESTRICTED => (READ_RESTRICTED | _Py_WRITE_RESTRICTED)
* gh-86493: Modernize modules initialization code (GH-106858)Serhiy Storchaka2023-07-251-25/+7
| | | | | Use PyModule_Add() or PyModule_AddObjectRef() instead of soft deprecated PyModule_AddObject().
* gh-104922: remove PY_SSIZE_T_CLEAN (#106315)Inada Naoki2023-07-021-2/+0
|
* Fix missing/incomplete NULL checks in multiple source files (#104564)chgnrdv2023-05-231-0/+3
| | | Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
* gh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (gh-104205)Eric Snow2023-05-051-0/+1
| | | Here we are doing no more than adding the value for Py_mod_multiple_interpreters and using it for stdlib modules. We will start checking for it in gh-104206 (once PyInterpreterState.ceval.own_gil is added in gh-104204).
* gh-101322: Ensure test_zlib.ZlibDecompressorTest runs, fix errors in ↵Ruben Vorderman2023-02-041-0/+1
| | | | | ZlibDecompressor (#101323) * Ensure test_zlib.ZlibDecompressorTest actually runs, fix errors in ZlibDecompressor.
* gh-99300: Use Py_NewRef() in Modules/ directory (#99473)Victor Stinner2022-11-141-35/+23
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in test C files of the Modules/ directory.
* gh-90110: Update the C-analyzer Tool (gh-99307)Eric Snow2022-11-101-1/+1
|
* Remove unused arrange_output_buffer function from zlibmodule.c. (GH-98358)Benjamin Peterson2022-10-171-16/+0
|
* gh-95534: Improve gzip reading speed by 10% (#97664)Ruben Vorderman2022-10-171-67/+571
| | | | | | | | | Change summary: + There is now a `gzip.READ_BUFFER_SIZE` constant that is 128KB. Other programs that read in 128KB chunks: pigz and cat. So this seems best practice among good programs. Also it is faster than 8 kb chunks. + a zlib._ZlibDecompressor was added. This is the _bz2.BZ2Decompressor ported to zlib. Since the zlib.Decompress object is better for in-memory decompression, the _ZlibDecompressor is hidden. It only makes sense in file decompression, and that is already implemented now in the gzip library. No need to bother the users with this. + The ZlibDecompressor uses the older Cpython arrange_output_buffer functions, as those are faster and more appropriate for the use case. + GzipFile.read has been optimized. There is no longer a `unconsumed_tail` member to write back to padded file. This is instead handled by the ZlibDecompressor itself, which has an internal buffer. `_add_read_data` has been inlined, as it was just two calls. EDIT: While I am adding improvements anyway, I figured I could add another one-liner optimization now to the python -m gzip application. That read chunks in io.DEFAULT_BUFFER_SIZE previously, but has been updated now to use READ_BUFFER_SIZE chunks.
* 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.