[Python-checkins] bpo-33671: allow setting shutil.copyfile() bufsize globally (GH-12016)

Inada Naoki webhook-mailer at python.org
Sun Feb 24 18:46:45 EST 2019


https://github.com/python/cpython/commit/3b0abb019662e42070f1d6f7e74440afb1808f03
commit: 3b0abb019662e42070f1d6f7e74440afb1808f03
branch: master
author: Giampaolo Rodola <g.rodola at gmail.com>
committer: Inada Naoki <methane at users.noreply.github.com>
date: 2019-02-25T08:46:40+09:00
summary:

bpo-33671: allow setting shutil.copyfile() bufsize globally (GH-12016)

files:
M Lib/shutil.py

diff --git a/Lib/shutil.py b/Lib/shutil.py
index 065e08bc5c34..29e7564622e1 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -187,9 +187,11 @@ def _copyfileobj_readinto(fsrc, fdst, length=COPY_BUFSIZE):
             else:
                 fdst_write(mv)
 
-def copyfileobj(fsrc, fdst, length=COPY_BUFSIZE):
+def copyfileobj(fsrc, fdst, length=0):
     """copy data from file-like object fsrc to file-like object fdst"""
     # Localize variable access to minimize overhead.
+    if not length:
+        length = COPY_BUFSIZE
     fsrc_read = fsrc.read
     fdst_write = fdst.write
     while True:



More information about the Python-checkins mailing list