summaryrefslogtreecommitdiffstats
path: root/Lib/shutil.py
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2019-10-01 03:40:54 (GMT)
committerGitHub <noreply@github.com>2019-10-01 03:40:54 (GMT)
commit94e165096fd65e8237e60de570fb609604ab94c9 (patch)
tree93b0c632a3869b8cbaa109dc9bb46b7140d84817 /Lib/shutil.py
parentcf57cabef82c4689ce9796bb1fcdb125fa05efcb (diff)
downloadcpython-94e165096fd65e8237e60de570fb609604ab94c9.zip
cpython-94e165096fd65e8237e60de570fb609604ab94c9.tar.gz
cpython-94e165096fd65e8237e60de570fb609604ab94c9.tar.bz2
bpo-38319: Fix shutil._fastcopy_sendfile(): set sendfile() max block size (GH-16491)
Diffstat (limited to 'Lib/shutil.py')
-rw-r--r--Lib/shutil.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py
index f0d0336..f97de78 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -135,9 +135,13 @@ def _fastcopy_sendfile(fsrc, fdst):
# should not make any difference, also in case the file content
# changes while being copied.
try:
- blocksize = max(os.fstat(infd).st_size, 2 ** 23) # min 8MB
- except Exception:
- blocksize = 2 ** 27 # 128MB
+ blocksize = max(os.fstat(infd).st_size, 2 ** 23) # min 8MiB
+ except OSError:
+ blocksize = 2 ** 27 # 128MiB
+ # On 32-bit architectures truncate to 1GiB to avoid OverflowError,
+ # see bpo-38319.
+ if sys.maxsize < 2 ** 32:
+ blocksize = min(blocksize, 2 ** 30)
offset = 0
while True: