New submission from Sebastien Bourdeauducq <s...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue33678>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to