]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Revert "gh-129005: _pyio.BufferedIO remove copy on readall (#129454)" (#129500)
authorCody Maloney <cmaloney@users.noreply.github.com>
Fri, 31 Jan 2025 08:40:44 +0000 (00:40 -0800)
committerGitHub <noreply@github.com>
Fri, 31 Jan 2025 08:40:44 +0000 (09:40 +0100)
This reverts commit e1c4ba928852eac0b0e0bded1c314e3e36975286.

Lib/_pyio.py
Misc/NEWS.d/next/Library/2025-01-29-00-00-01.gh-issue-129005.aV_3O8.rst [deleted file]

index 755e025877089136af068a8edafc1070ed08b3dd..76a27910da4d5f375508881b565373dc523e9bfe 100644 (file)
@@ -1062,9 +1062,6 @@ class BufferedReader(_BufferedIOMixin):
                 if chunk is None:
                     return buf[pos:] or None
                 else:
-                    # Avoid slice + copy if there is no data in buf
-                    if not buf:
-                        return chunk
                     return buf[pos:] + chunk
             chunks = [buf[pos:]]  # Strip the consumed bytes.
             current_size = 0
diff --git a/Misc/NEWS.d/next/Library/2025-01-29-00-00-01.gh-issue-129005.aV_3O8.rst b/Misc/NEWS.d/next/Library/2025-01-29-00-00-01.gh-issue-129005.aV_3O8.rst
deleted file mode 100644 (file)
index 48ee571..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-:mod:`!_pyio`: Remove an unnecessary copy when ``_pyio.BufferedReader.read()``
-is called to read all data from a file and has no data already in buffer.