[New-bugs-announce] [issue33678] selector_events.BaseSelectorEventLoop.sock_connect should preserve socket type

Sebastien Bourdeauducq report at bugs.python.org
Tue May 29 05:43:27 EDT 2018


New submission from Sebastien Bourdeauducq <sb at m-labs.hk>:

The current behavior causes an exception to be raised when trying to create a datagram socket and _ipaddr_info returns None (since asyncio then calls loop.getaddrinfo with SOCK_STREAM and IPPROTO_UDP).

Preserving socket type is made difficult by https://bugs.python.org/issue21327; the proposed patch includes a dirty workaround. I do not know yet if it works on Windows.

--- selector_events.py  2018-05-11 10:01:42.011164837 +0800
+++ selector_events.py.new      2018-05-29 17:41:03.103155480 +0800
@@ -439,8 +439,9 @@
             raise ValueError("the socket must be non-blocking")
 
         if not hasattr(socket, 'AF_UNIX') or sock.family != socket.AF_UNIX:
+            socktype = sock.type & 0xf  # WA https://bugs.python.org/issue21327
             resolved = base_events._ensure_resolved(
-                address, family=sock.family, proto=sock.proto, loop=self)
+                address, family=sock.family, type=socktype, proto=sock.proto, loop=self)
             if not resolved.done():
                 yield from resolved
             _, _, _, _, address = resolved.result()[0]

----------
components: asyncio
messages: 318001
nosy: asvetlov, sebastien.bourdeauducq, yselivanov
priority: normal
severity: normal
status: open
title: selector_events.BaseSelectorEventLoop.sock_connect should preserve socket type
type: behavior
versions: Python 3.5, Python 3.6

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


More information about the New-bugs-announce mailing list