bpo-45475: Revert __iter__ optimization for GzipFile, BZ2File, and LZMAFile. (GH-29016)

This reverts commit d2a8e69c2c.
(cherry picked from commit 0a4c82ddd3)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-10-18 20:15:48 -07:00 committed by GitHub
parent b1949e0b58
commit 97ce855ca8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 12 deletions

View file

@ -197,10 +197,6 @@ class BZ2File(_compression.BaseStream):
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.

View file

@ -398,10 +398,6 @@ class GzipFile(_compression.BaseStream):
self._check_not_closed()
return self._buffer.readline(size)
def __iter__(self):
self._check_not_closed()
return self._buffer.__iter__()
class _GzipReader(_compression.DecompressReader):
def __init__(self, fp):

View file

@ -221,10 +221,6 @@ class LZMAFile(_compression.BaseStream):
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.

View file

@ -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.