From edd8fcda16014e3e3ba49d2b9103eed192292138 Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Mon, 13 Feb 2023 08:53:14 +0100 Subject: [PATCH 1/3] Update embedded zlib-ng version to 2.0.7 --- src/zlib_ng/zlib-ng | 2 +- tests/test_compat.py | 28 +++------------------------- tests/test_zlib_compliance.py | 4 ---- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/src/zlib_ng/zlib-ng b/src/zlib_ng/zlib-ng index b56a2fd..a583e21 160000 --- a/src/zlib_ng/zlib-ng +++ b/src/zlib_ng/zlib-ng @@ -1 +1 @@ -Subproject commit b56a2fd0b126cfe5f13e68ab9090cd4f6a773286 +Subproject commit a583e215afa2356e23b418efa871a1cc4348702a diff --git a/tests/test_compat.py b/tests/test_compat.py index 7595cbe..12dda97 100644 --- a/tests/test_compat.py +++ b/tests/test_compat.py @@ -82,14 +82,7 @@ def test_adler32(data_size, value): def test_compress(data_size, level, wbits): data = DATA[:data_size] compressed = zlib_ng.compress(data, level=level, wbits=wbits) - try: - decompressed = zlib.decompress(compressed, wbits) - except zlib.error: - # Known bug in zlib-ng 2.0.6. Wbits is not correctly applied for level 1. - if (zlib_ng.ZLIBNG_VERSION == "2.0.6" and - level == 1 and - wbits & 0b1111 < 13): - pytest.xfail() + decompressed = zlib.decompress(compressed, wbits) assert decompressed == data @@ -118,15 +111,7 @@ def test_decompress_wbits(data_size, level, wbits, memLevel, strategy): def test_decompress_zlib_ng(data_size, level, wbits): data = DATA[:data_size] compressed = zlib_ng.compress(data, level=level, wbits=wbits) - try: - decompressed = zlib_ng.decompress(compressed, wbits=wbits) - except zlib_ng.error: - # Known bug in zlib-ng 2.0.6. Wbits is not correctly applied for level 1. - if (zlib_ng.ZLIBNG_VERSION == "2.0.6" and - level == 1 and - wbits & 0b1111 < 13): - pytest.xfail() - assert decompressed == data + decompressed = zlib_ng.decompress(compressed, wbits=wbits) assert decompressed == data @@ -139,14 +124,7 @@ def test_compress_compressobj(data_size, level, wbits, memLevel, strategy): memLevel=memLevel, strategy=strategy) compressed = compressobj.compress(data) + compressobj.flush() - try: - decompressed = zlib.decompress(compressed, wbits=wbits) - except zlib.error: - # Known bug in zlib-ng 2.0.6. Wbits is not correctly applied for level 1. - if (zlib_ng.ZLIBNG_VERSION == "2.0.6" and - level == 1 and - wbits & 0b1111 < 13): - pytest.xfail() + decompressed = zlib.decompress(compressed, wbits=wbits) assert data == decompressed diff --git a/tests/test_zlib_compliance.py b/tests/test_zlib_compliance.py index 3060128..1f8ff53 100644 --- a/tests/test_zlib_compliance.py +++ b/tests/test_zlib_compliance.py @@ -835,10 +835,6 @@ def test_large_unconsumed_tail(self, size): finally: comp = uncomp = data = None - # TODO: zlib-ng does not handle wbits for the zlib header correctly. - # TODO: latest zlib-ng works correctly. Should be fixed when new release - # TODO: of zlib-ng comes. - @unittest.expectedFailure def test_wbits(self): # wbits=0 only supported since zlib v1.2.3.5 # Register "1.2.3" as "1.2.3.0" From f612ebeb7815fe16193e3391543954b55d4c50d0 Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Mon, 20 Mar 2023 06:55:27 +0100 Subject: [PATCH 2/3] Update changelog with zlib-ng update --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 31ab2ef..a4ade92 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,6 +9,7 @@ Changelog version 0.2.0-dev ----------------- ++ Update embedded zlib-ng version to 2.0.7 + Escape GIL for adler32 and crc32 functions. version 0.1.0 From 281f7ad02ee573cf1dc6683cab1ce757c1d44b5a Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Mon, 20 Mar 2023 06:57:51 +0100 Subject: [PATCH 3/3] Require at least 2.0.7 version in source --- README.rst | 7 +------ src/zlib_ng/zlib_ngmodule.c | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index e1a551c..eef79dc 100644 --- a/README.rst +++ b/README.rst @@ -120,13 +120,8 @@ Differences with zlib and gzip modules .. differences start -+ Compression level 1 zlib_ng has a much worse compression rate than that in ++ Compression level 1 zlib_ng has a worse compression rate than that in zlib. For other compression levels zlib_ng compresses better. -+ Compression level 1 does not apply requested ``wbits`` correctly. For example - compressing with ``zlib_ng.compress(data, level=1, wbits=-9)`` results in - data that cannot be decompressed with ``zlib_ng.decompress(data, wbits=-9)`` - as this will throw an error mentioning invalid window sizes. This is a - bug in the included zlib-ng 2.0.6. + ``gzip_ng.open`` returns a class ``GzipNGFile`` instead of ``GzipFile``. Since there are differences between the compressed ratios between levels, a difference in naming was chosen to reflect this. diff --git a/src/zlib_ng/zlib_ngmodule.c b/src/zlib_ng/zlib_ngmodule.c index 3e5f7ae..5ecedb3 100644 --- a/src/zlib_ng/zlib_ngmodule.c +++ b/src/zlib_ng/zlib_ngmodule.c @@ -9,8 +9,8 @@ #include "stdbool.h" #include "stdint.h" -#if defined(ZLIBNG_VERNUM) && ZLIBNG_VERNUM < 0x02060 -#error "At least zlib-ng version 2.0.6 is required" +#if defined(ZLIBNG_VERNUM) && ZLIBNG_VERNUM < 0x02070 +#error "At least zlib-ng version 2.0.7 is required" #endif #define ENTER_ZLIB(obj) do { \