]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41467: Fix asyncio recv_into() on Windows (GH-21720)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 4 Aug 2020 00:58:06 +0000 (17:58 -0700)
committerGitHub <noreply@github.com>
Tue, 4 Aug 2020 00:58:06 +0000 (17:58 -0700)
On Windows, fix asyncio recv_into() return value when the socket/pipe
is closed (BrokenPipeError): return 0 rather than an empty byte
string (b'').
(cherry picked from commit 602a971a2af3a685d625c912c400cadd452718b1)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/asyncio/windows_events.py
Misc/NEWS.d/next/Library/2020-08-04-00-20-30.bpo-41467.Z8DgTL.rst [new file with mode: 0644]

index ac51109ff1a83d5fe657f4d3a2109a5c2ecd77c1..12e87abfbf2ea0086ceb62cc98a233338bc0a740 100644 (file)
@@ -469,7 +469,7 @@ class IocpProactor:
             else:
                 ov.ReadFileInto(conn.fileno(), buf)
         except BrokenPipeError:
-            return self._result(b'')
+            return self._result(0)
 
         def finish_recv(trans, key, ov):
             try:
diff --git a/Misc/NEWS.d/next/Library/2020-08-04-00-20-30.bpo-41467.Z8DgTL.rst b/Misc/NEWS.d/next/Library/2020-08-04-00-20-30.bpo-41467.Z8DgTL.rst
new file mode 100644 (file)
index 0000000..f12693e
--- /dev/null
@@ -0,0 +1,3 @@
+On Windows, fix asyncio ``recv_into()`` return value when the socket/pipe is
+closed (:exc:`BrokenPipeError`): return ``0`` rather than an empty byte
+string (``b''``).