Skip to content

gh-123174: Add proto parameter to sock_connect #123175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Lib/asyncio/selector_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def _sock_sendto(self, fut, sock, data, address):
else:
fut.set_result(n)

async def sock_connect(self, sock, address):
async def sock_connect(self, sock, address, proto_addr_info=None):
"""Connect to a remote socket at address.

This method is a coroutine.
Expand All @@ -629,8 +629,9 @@ async def sock_connect(self, sock, address):

if sock.family == socket.AF_INET or (
base_events._HAS_IPv6 and sock.family == socket.AF_INET6):
proto = proto_addr_info if proto_addr_info is not None else sock.proto
resolved = await self._ensure_resolved(
address, family=sock.family, type=sock.type, proto=sock.proto,
address, family=sock.family, type=sock.type, proto=proto,
loop=self,
)
_, _, _, _, address = resolved[0]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Allow the selection of the protocol used by getaddrinfo by adding an additional, optional parameter proto_addr_info
If not specified, use the protocol used by the socket (= previous behaviour)
Loading