Sendfile on Solaris can raise EINVAL if offset is bigger than size of the file. Because this would not send any data anyway, we can safely avoid calling this function at all. --- Python-3.8.0a3/Lib/socket.py +++ Python-3.8.0a3/Lib/socket.py @@ -301,6 +301,10 @@ class socket(_socket.socket): blocksize = count - total_sent if blocksize <= 0: break + # Sendfile on Solaris can raise EINVAL if offset >= size of the file. + # In that case don't call it at all. + elif offset >= fsize: + break; try: sent = os_sendfile(sockno, fileno, offset, blocksize) except BlockingIOError: --- Python-3.8.0a3/Lib/asyncio/unix_events.py +++ Python-3.8.0a3/Lib/asyncio/unix_events.py @@ -357,6 +357,12 @@ class _UnixSelectorEventLoop(selector_ev self._sock_sendfile_update_filepos(fileno, offset, total_sent) fut.set_result(total_sent) return + # Sendfile on Solaris can raise EINVAL if offset >= size of the file. + # In that case don't call it at all. + elif offset >= blocksize: + self._sock_sendfile_update_filepos(fileno, offset, total_sent) + fut.set_result(total_sent) + return try: sent = os.sendfile(fd, fileno, offset, blocksize)