Skip to content

Commit 883f158

Browse files
author
Bojan Nikolic
committed
Split handling of ENOTSOCK and ENODATA
1 parent 482fb09 commit 883f158

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Lib/shutil.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,16 @@ def _fastcopy_sendfile(fsrc, fdst):
206206
err.filename = fsrc.name
207207
err.filename2 = fdst.name
208208

209-
if err.errno in (errno.ENOTSOCK, errno.ENODATA):
209+
if err.errno == errno.ENOTSOCK:
210210
# ENOTSOCK: sendfile() on this platform (probably
211211
# Linux < 2.6.33) does not support copies between
212212
# regular files (only sockets).
213-
#
214-
# ENODATA: In rare cases, sendfile() on Linux Lustre
215-
# returns ENODATA.
213+
_USE_CP_SENDFILE = False
214+
raise _GiveupOnFastCopy(err)
215+
216+
if err.errno == errno.ENODATA:
217+
# In rare cases, sendfile() on Linux Lustre returns
218+
# ENODATA.
216219
_USE_CP_SENDFILE = False
217220

218221
dstpos = os.lseek(outfd, 0, os.SEEK_CUR)
@@ -224,7 +227,7 @@ def _fastcopy_sendfile(fsrc, fdst):
224227
# back on POSIX read/write method
225228
os.lseek(infd, dstpos, os.SEEK_SET)
226229

227-
raise _GiveupOnFastCopy(err)
230+
raise _GiveupOnFastCopy(err)
228231

229232
if err.errno == errno.ENOSPC: # filesystem is full
230233
raise err from None

0 commit comments

Comments
 (0)