From 0b8807e41b4ec7bff4dd98114235b4f26d612efe Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Tue, 11 Jul 2023 12:37:52 -0400 Subject: [PATCH] Replace IndexedGzipFile.__reduce__ with IndexedGzipFile.__reduce_ex__ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restores “pickle-ability” of IndexedGzipFile in Python 3.12, which was broken due to https://github.com/python/cpython/pull/101948. --- indexed_gzip/indexed_gzip.pyx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/indexed_gzip/indexed_gzip.pyx b/indexed_gzip/indexed_gzip.pyx index eef93983..5da4e6a5 100644 --- a/indexed_gzip/indexed_gzip.pyx +++ b/indexed_gzip/indexed_gzip.pyx @@ -169,9 +169,11 @@ class IndexedGzipFile(io.BufferedReader): return self.read(nbytes) - def __reduce__(self): + def __reduce_ex__(self, protocol): """Used to pickle an ``IndexedGzipFile``. + :arg protocol: Pickle protocol version + Returns a tuple containing: - a reference to the ``unpickle`` function - a tuple containing a "state" object, which can be passed @@ -1093,7 +1095,7 @@ def unpickle(state): """Create a new ``IndexedGzipFile`` from a pickled state. :arg state: State of a pickled object, as returned by the - ``IndexedGzipFile.__reduce__`` method. + ``IndexedGzipFile.__reduce_ex__`` method. :returns: A new ``IndexedGzipFile`` object. """