New submission from Cecile Tonglet: The IPv6 detection in asyncio.base_events.create_server only detect if IPv6 is available instead of checking if the interface can actually support it.
I noticed that by using Python in a Docker container (example code to reproduce in attachment): docker run -it --rm -v /tmp/test_ipv6.py:/src/test_ipv6.py python:3.6 python /src/test_ipv6.py Will result in: Traceback (most recent call last): File "/usr/local/lib/python3.6/asyncio/base_events.py", line 1043, in create_server sock.bind(sa) OSError: [Errno 99] Cannot assign requested address During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/src/test_ipv6.py", line 11, in <module> server = loop.run_until_complete(server_creation) File "/usr/local/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete return future.result() File "/usr/local/lib/python3.6/asyncio/base_events.py", line 1047, in create_server % (sa, err.strerror.lower())) OSError: [Errno 99] error while attempting to bind on address ('::1', 27015, 0, 0): cannot assign requested address By default Docker containers have only IPv4 enabled: 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 38: eth0@if39: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff inet 172.17.0.2/16 scope global eth0 valid_lft forever preferred_lft forever I believe this detection mechanism should rely on the interface requested. I found this on the web for Python 2 that manage to get the info per interface: https://pastebin.com/VEnhF1Ht but it's using an external library. However if you change the hostname to 127.0.0.1 it works normally. ---------- components: asyncio files: test_ipv6.py messages: 298474 nosy: cecton, yselivanov priority: normal severity: normal status: open title: loop.create_server does not detect if the interface is IPv6 enabled type: behavior versions: Python 3.4, Python 3.5, Python 3.6 Added file: http://bugs.python.org/file47019/test_ipv6.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30945> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com