Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0b8807e

Browse files
committedJul 11, 2023
Replace IndexedGzipFile.__reduce__ with IndexedGzipFile.__reduce_ex__
Restores “pickle-ability” of IndexedGzipFile in Python 3.12, which was broken due to python/cpython#101948.
1 parent 16229b9 commit 0b8807e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

‎indexed_gzip/indexed_gzip.pyx

+4-2
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,11 @@ class IndexedGzipFile(io.BufferedReader):
169169
return self.read(nbytes)
170170

171171

172-
def __reduce__(self):
172+
def __reduce_ex__(self, protocol):
173173
"""Used to pickle an ``IndexedGzipFile``.
174174
175+
:arg protocol: Pickle protocol version
176+
175177
Returns a tuple containing:
176178
- a reference to the ``unpickle`` function
177179
- a tuple containing a "state" object, which can be passed
@@ -1093,7 +1095,7 @@ def unpickle(state):
10931095
"""Create a new ``IndexedGzipFile`` from a pickled state.
10941096
10951097
:arg state: State of a pickled object, as returned by the
1096-
``IndexedGzipFile.__reduce__`` method.
1098+
``IndexedGzipFile.__reduce_ex__`` method.
10971099
10981100
:returns: A new ``IndexedGzipFile`` object.
10991101
"""

0 commit comments

Comments
 (0)
Please sign in to comment.