Skip to content

bpo-45475: Revert __iter__ optimization for GzipFile, BZ2File, and LZMAFile. #29016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Lib/bz2.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,6 @@ def readline(self, size=-1):
self._check_can_read()
return self._buffer.readline(size)

def __iter__(self):
self._check_can_read()
return self._buffer.__iter__()

def readlines(self, size=-1):
"""Read a list of lines of uncompressed bytes from the file.

Expand Down
4 changes: 0 additions & 4 deletions Lib/gzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,6 @@ def readline(self, size=-1):
self._check_not_closed()
return self._buffer.readline(size)

def __iter__(self):
self._check_not_closed()
return self._buffer.__iter__()


def _read_exact(fp, n):
'''Read exactly *n* bytes from `fp`
Expand Down
4 changes: 0 additions & 4 deletions Lib/lzma.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,6 @@ def readline(self, size=-1):
self._check_can_read()
return self._buffer.readline(size)

def __iter__(self):
self._check_can_read()
return self._buffer.__iter__()

def write(self, data):
"""Write a bytes object to the file.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Reverted optimization of iterating :class:`gzip.GzipFile`,
:class:`bz2.BZ2File`, and :class:`lzma.LZMAFile` (see bpo-43787) because it
caused regression when user iterate them without having reference of them.
Patch by Inada Naoki.