[New-bugs-announce] [issue41467] asyncio: recv_into() must not return b'' if the socket/pipe is closed

STINNER Victor report at bugs.python.org
Mon Aug 3 18:19:49 EDT 2020


New submission from STINNER Victor <vstinner at python.org>:

The proactor event loop of asyncio returns b'' on recv_into() if the socket/pipe is closed:

    def recv_into(self, conn, buf, flags=0):
        ...
        try:
            ...
        except BrokenPipeError:
            return self._result(b'')
        ...

But a socket recv_into() must always return a number: the number of written bytes. Example with socket.socket.recv_into() method:
https://docs.python.org/3/library/socket.html#socket.socket.recv_into

IMHO zero must be returned here. This bug may be the root cause of bpo-38912 bug.

Attached PR fix the issue.

----------
components: asyncio
messages: 374760
nosy: asvetlov, vstinner, yselivanov
priority: normal
severity: normal
status: open
title: asyncio: recv_into() must not return b'' if the socket/pipe is closed
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41467>
_______________________________________


More information about the New-bugs-announce mailing list