diff options
author | Inada Naoki <songofacandy@gmail.com> | 2021-10-19 02:51:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-19 02:51:48 (GMT) |
commit | 0a4c82ddd34a3578684b45b76f49cd289a08740b (patch) | |
tree | 0eb1d0c76d12a62838552a4be7d62306747a0815 | |
parent | c0295675305f6896e4ba7496441cc470d7edca89 (diff) | |
download | cpython-0a4c82ddd34a3578684b45b76f49cd289a08740b.zip cpython-0a4c82ddd34a3578684b45b76f49cd289a08740b.tar.gz cpython-0a4c82ddd34a3578684b45b76f49cd289a08740b.tar.bz2 |
bpo-45475: Revert `__iter__` optimization for GzipFile, BZ2File, and LZMAFile. (GH-29016)
This reverts commit d2a8e69c2c605fbaa3656a5f99aa8d295f74c80e.
-rw-r--r-- | Lib/bz2.py | 4 | ||||
-rw-r--r-- | Lib/gzip.py | 4 | ||||
-rw-r--r-- | Lib/lzma.py | 4 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2021-10-18-10-46-47.bpo-45475.sb9KDF.rst | 4 |
4 files changed, 4 insertions, 12 deletions
@@ -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. diff --git a/Lib/gzip.py b/Lib/gzip.py index 0dddb51..ac17810 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -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__() - def _read_exact(fp, n): '''Read exactly *n* bytes from `fp` diff --git a/Lib/lzma.py b/Lib/lzma.py index 9abf06d..800f521 100644 --- a/Lib/lzma.py +++ b/Lib/lzma.py @@ -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. diff --git a/Misc/NEWS.d/next/Library/2021-10-18-10-46-47.bpo-45475.sb9KDF.rst b/Misc/NEWS.d/next/Library/2021-10-18-10-46-47.bpo-45475.sb9KDF.rst new file mode 100644 index 0000000..6fce894 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-10-18-10-46-47.bpo-45475.sb9KDF.rst @@ -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. |