Skip to content

Commit 0a4c82d

Browse files
authored
bpo-45475: Revert __iter__ optimization for GzipFile, BZ2File, and LZMAFile. (GH-29016)
This reverts commit d2a8e69.
1 parent c029567 commit 0a4c82d

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

Lib/bz2.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,6 @@ def readline(self, size=-1):
197197
self._check_can_read()
198198
return self._buffer.readline(size)
199199

200-
def __iter__(self):
201-
self._check_can_read()
202-
return self._buffer.__iter__()
203-
204200
def readlines(self, size=-1):
205201
"""Read a list of lines of uncompressed bytes from the file.
206202

Lib/gzip.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,6 @@ def readline(self, size=-1):
398398
self._check_not_closed()
399399
return self._buffer.readline(size)
400400

401-
def __iter__(self):
402-
self._check_not_closed()
403-
return self._buffer.__iter__()
404-
405401

406402
def _read_exact(fp, n):
407403
'''Read exactly *n* bytes from `fp`

Lib/lzma.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,6 @@ def readline(self, size=-1):
221221
self._check_can_read()
222222
return self._buffer.readline(size)
223223

224-
def __iter__(self):
225-
self._check_can_read()
226-
return self._buffer.__iter__()
227-
228224
def write(self, data):
229225
"""Write a bytes object to the file.
230226
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Reverted optimization of iterating :class:`gzip.GzipFile`,
2+
:class:`bz2.BZ2File`, and :class:`lzma.LZMAFile` (see bpo-43787) because it
3+
caused regression when user iterate them without having reference of them.
4+
Patch by Inada Naoki.

0 commit comments

Comments
 (0)