Skip to content

Commit b934d83

Browse files
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 602a971) Co-authored-by: Victor Stinner <[email protected]>
1 parent 4bc8445 commit b934d83

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Lib/asyncio/windows_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def recv_into(self, conn, buf, flags=0):
469469
else:
470470
ov.ReadFileInto(conn.fileno(), buf)
471471
except BrokenPipeError:
472-
return self._result(b'')
472+
return self._result(0)
473473

474474
def finish_recv(trans, key, ov):
475475
try:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
On Windows, fix asyncio ``recv_into()`` return value when the socket/pipe is
2+
closed (:exc:`BrokenPipeError`): return ``0`` rather than an empty byte
3+
string (``b''``).

0 commit comments

Comments
 (0)