bpo-41467: Fix asyncio recv_into() on Windows (GH-21720)

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 602a971a2a)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2020-08-03 17:58:06 -07:00 committed by GitHub
parent 4bc8445c39
commit b934d832d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View 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:

View File

@ -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''``).