Skip to content

asyncio ProactorEventLoop didn't check if the socket is blocking #113892

Closed
@NewUserHa

Description

@NewUserHa

Bug report

Bug description:

import asyncio
import socket

s = socket.socket()
await asyncio.get_running_loop().sock_connect(s,('127.0.0.1',80))

according to https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.sock_connect and

async def sock_connect(self, sock, address):
"""Connect to a remote socket at address.
This method is a coroutine.
"""
base_events._check_ssl_socket(sock)
if self._debug and sock.gettimeout() != 0:
raise ValueError("the socket must be non-blocking")
if sock.family == socket.AF_INET or (
base_events._HAS_IPv6 and sock.family == socket.AF_INET6):
resolved = await self._ensure_resolved(
address, family=sock.family, type=sock.type, proto=sock.proto,
loop=self,

it should raise. however, ProactorEventLoop doesn't follow the rule

should we fix this, any thoughts

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

Labels

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions