From 87c88faa88c33cdc927868a09025ab23f77c0208 Mon Sep 17 00:00:00 2001 From: AN Long Date: Thu, 23 Nov 2023 22:26:20 +0800 Subject: [PATCH] using transmitfile for sendfile on windows --- Lib/socket.py | 2 ++ .../next/Windows/2023-11-23-22-25-16.gh-issue-65920.6wWsHN.rst | 1 + 2 files changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Windows/2023-11-23-22-25-16.gh-issue-65920.6wWsHN.rst diff --git a/Lib/socket.py b/Lib/socket.py index b1d66574620..431cbb39e6d 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -514,6 +514,8 @@ def sendfile(self, file, offset=0, count=None): The socket must be of SOCK_STREAM type. Non-blocking sockets are not supported. """ + if sys.platform == "win32": + return self._sendfile_use_transmitfile(file, offset, count) try: return self._sendfile_use_sendfile(file, offset, count) except _GiveupOnSendfile: diff --git a/Misc/NEWS.d/next/Windows/2023-11-23-22-25-16.gh-issue-65920.6wWsHN.rst b/Misc/NEWS.d/next/Windows/2023-11-23-22-25-16.gh-issue-65920.6wWsHN.rst new file mode 100644 index 00000000000..ff0923890ea --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2023-11-23-22-25-16.gh-issue-65920.6wWsHN.rst @@ -0,0 +1 @@ +Use ``TransmitFile`` on Windows to implement ``socket.sendfile``.