Skip to content

Commit

Permalink
Replace IndexedGzipFile.__reduce__ with IndexedGzipFile.__reduce_ex__
Browse files Browse the repository at this point in the history
Restores “pickle-ability” of IndexedGzipFile in Python 3.12, which was
broken due to python/cpython#101948.
  • Loading branch information
musicinmybrain committed Jul 11, 2023
1 parent 16229b9 commit 0b8807e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions indexed_gzip/indexed_gzip.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
"""
Expand Down

0 comments on commit 0b8807e

Please sign in to comment.