5050 import nt
5151
5252COPY_BUFSIZE = 1024 * 1024 if _WINDOWS else 64 * 1024
53- _HAS_SENDFILE = posix and hasattr (os , "sendfile" )
53+ _USE_CP_SENDFILE = hasattr (os , "sendfile" ) and sys . platform . startswith ( "linux " )
5454_HAS_FCOPYFILE = posix and hasattr (posix , "_fcopyfile" ) # macOS
5555
5656__all__ = ["copyfileobj" , "copyfile" , "copymode" , "copystat" , "copy" , "copy2" ,
@@ -111,7 +111,7 @@ def _fastcopy_fcopyfile(fsrc, fdst, flags):
111111def _fastcopy_sendfile (fsrc , fdst ):
112112 """Copy data from one regular mmap-like fd to another by using
113113 high-performance sendfile(2) syscall.
114- This should work on Linux >= 2.6.33 and Solaris only.
114+ This should work on Linux >= 2.6.33 only.
115115 """
116116 # Note: copyfileobj() is left alone in order to not introduce any
117117 # unexpected breakage. Possible risks by using zero-copy calls
@@ -122,7 +122,7 @@ def _fastcopy_sendfile(fsrc, fdst):
122122 # GzipFile (which decompresses data), HTTPResponse (which decodes
123123 # chunks).
124124 # - possibly others (e.g. encrypted fs/partition?)
125- global _HAS_SENDFILE
125+ global _USE_CP_SENDFILE
126126 try :
127127 infd = fsrc .fileno ()
128128 outfd = fdst .fileno ()
@@ -152,7 +152,7 @@ def _fastcopy_sendfile(fsrc, fdst):
152152 # sendfile() on this platform (probably Linux < 2.6.33)
153153 # does not support copies between regular files (only
154154 # sockets).
155- _HAS_SENDFILE = False
155+ _USE_CP_SENDFILE = False
156156 raise _GiveupOnFastCopy (err )
157157
158158 if err .errno == errno .ENOSPC : # filesystem is full
@@ -260,8 +260,8 @@ def copyfile(src, dst, *, follow_symlinks=True):
260260 return dst
261261 except _GiveupOnFastCopy :
262262 pass
263- # Linux / Solaris
264- elif _HAS_SENDFILE :
263+ # Linux
264+ elif _USE_CP_SENDFILE :
265265 try :
266266 _fastcopy_sendfile (fsrc , fdst )
267267 return dst
0 commit comments