From dc647e28f5b55193f09390aa4d0e43c3f1458615 Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Mon, 25 Dec 2023 17:06:12 +0100 Subject: [PATCH 1/5] Set new version --- setup.py | 2 +- src/zlib_ng/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index fdace0f..2a34c5e 100644 --- a/setup.py +++ b/setup.py @@ -123,7 +123,7 @@ def build_zlib_ng(): setup( name="zlib-ng", - version="0.4.0", + version="0.5.0-dev", description="Drop-in replacement for zlib and gzip modules using zlib-ng", author="Leiden University Medical Center", author_email="r.h.p.vorderman@lumc.nl", # A placeholder for now diff --git a/src/zlib_ng/__init__.py b/src/zlib_ng/__init__.py index 5d5979e..aa9ea12 100644 --- a/src/zlib_ng/__init__.py +++ b/src/zlib_ng/__init__.py @@ -5,4 +5,4 @@ # This file is part of python-zlib-ng which is distributed under the # PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2. -__version__ = "0.4.0" +__version__ = "0.5.0-dev" From 5f9a9b6a1054629a35d2fdf5d94508166b1b6f43 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Tue, 23 Jan 2024 08:02:11 -0500 Subject: [PATCH 2/5] Replace internal API _PyBytes_Join, removed in Python 3.13 --- src/zlib_ng/zlib_ngmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zlib_ng/zlib_ngmodule.c b/src/zlib_ng/zlib_ngmodule.c index d0e528a..79fa29d 100644 --- a/src/zlib_ng/zlib_ngmodule.c +++ b/src/zlib_ng/zlib_ngmodule.c @@ -2810,7 +2810,7 @@ GzipReader_readall(GzipReader *self, PyObject *Py_UNUSED(ignore)) Py_DECREF(chunk_list); return NULL; } - PyObject *ret = _PyBytes_Join(empty_bytes, chunk_list); + PyObject *ret = PyObject_CallMethod(empty_bytes, "join", "O", chunk_list); Py_DECREF(empty_bytes); Py_DECREF(chunk_list); return ret; From 1c63077186a42a49f29d63461c8316f4ea0d4bbb Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Tue, 23 Jan 2024 08:31:48 -0500 Subject: [PATCH 3/5] Add a changelog entry for PR#31 --- CHANGELOG.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6a38039..93fbe10 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,10 @@ Changelog .. This document is user facing. Please word the changes in such a way .. that users understand how the changes affect the new version. +version 0.5.0-dev +----------------- ++ Fix compatibility with Python 3.13 + version 0.4.0 ----------------- + Add a ``gzip_ng_threaded`` module that contains the ``gzip_ng_threaded.open`` From 6289b3a3db342dc913e3d8d7eb104424173a57f2 Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Mon, 11 Mar 2024 13:50:26 +0100 Subject: [PATCH 4/5] gzip_ng_threaded.open no longer closes streams passed to it --- CHANGELOG.rst | 2 ++ src/zlib_ng/gzip_ng_threaded.py | 14 +++++++++----- tests/test_gzip_ng_threaded.py | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 93fbe10..50b201a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,6 +9,8 @@ Changelog version 0.5.0-dev ----------------- ++ Fix a bug where streams that were passed to gzip_ng_threaded.open where + closed. + Fix compatibility with Python 3.13 version 0.4.0 diff --git a/src/zlib_ng/gzip_ng_threaded.py b/src/zlib_ng/gzip_ng_threaded.py index f8c0820..5b8a9ff 100644 --- a/src/zlib_ng/gzip_ng_threaded.py +++ b/src/zlib_ng/gzip_ng_threaded.py @@ -78,16 +78,18 @@ def open(filename, mode="rb", compresslevel=gzip_ng._COMPRESS_LEVEL_TRADEOFF, def open_as_binary_stream(filename, open_mode): if isinstance(filename, (str, bytes)) or hasattr(filename, "__fspath__"): binary_file = builtins.open(filename, open_mode) + closefd = True elif hasattr(filename, "read") or hasattr(filename, "write"): binary_file = filename + closefd = False else: raise TypeError("filename must be a str or bytes object, or a file") - return binary_file + return binary_file, closefd class _ThreadedGzipReader(io.RawIOBase): def __init__(self, filename, queue_size=2, block_size=1024 * 1024): - self.raw = open_as_binary_stream(filename, "rb") + self.raw, self.closefd = open_as_binary_stream(filename, "rb") self.fileobj = zlib_ng._GzipReader(self.raw, buffersize=8 * block_size) self.pos = 0 self.read_file = False @@ -155,7 +157,8 @@ def close(self) -> None: self.running = False self.worker.join() self.fileobj.close() - self.raw.close() + if self.closefd: + self.raw.close() self._closed = True @property @@ -246,7 +249,7 @@ def __init__(self, self._crc = 0 self.running = False self._size = 0 - self.raw = open_as_binary_stream(filename, mode) + self.raw, self.closefd = open_as_binary_stream(filename, mode) self._closed = False self._write_gzip_header() self.start() @@ -334,7 +337,8 @@ def close(self) -> None: trailer = struct.pack(" Date: Mon, 11 Mar 2024 14:11:09 +0100 Subject: [PATCH 5/5] Set stable version --- CHANGELOG.rst | 2 +- setup.py | 2 +- src/zlib_ng/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 50b201a..0d447b5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,7 +7,7 @@ Changelog .. This document is user facing. Please word the changes in such a way .. that users understand how the changes affect the new version. -version 0.5.0-dev +version 0.4.1 ----------------- + Fix a bug where streams that were passed to gzip_ng_threaded.open where closed. diff --git a/setup.py b/setup.py index 2a34c5e..fc336a6 100644 --- a/setup.py +++ b/setup.py @@ -123,7 +123,7 @@ def build_zlib_ng(): setup( name="zlib-ng", - version="0.5.0-dev", + version="0.4.1", description="Drop-in replacement for zlib and gzip modules using zlib-ng", author="Leiden University Medical Center", author_email="r.h.p.vorderman@lumc.nl", # A placeholder for now diff --git a/src/zlib_ng/__init__.py b/src/zlib_ng/__init__.py index aa9ea12..53c4ac5 100644 --- a/src/zlib_ng/__init__.py +++ b/src/zlib_ng/__init__.py @@ -5,4 +5,4 @@ # This file is part of python-zlib-ng which is distributed under the # PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2. -__version__ = "0.5.0-dev" +__version__ = "0.4.1"