Issue 33206: Windows inet_pton(socket.AF_INET6, 'localhost') raises ValueError instead of socket.error (original) (raw)
Issue33206
Created on 2018-04-02 17:18 by vitaly.krug, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Messages (5) | ||
---|---|---|
msg314814 - (view) | Author: Vitaly Kruglikov (vitaly.krug) | Date: 2018-04-02 17:18 |
I am seeing this with `socket.AF_INET6` on Windows running python 2.7.14 ``` [00:02:33] File "C:\projects\pika\pika\adapters\host_tcp_connector.py", line 153, in _check_already_resolved [00:02:33] socket.inet_pton(socket.AF_INET6, 'localhost') [00:02:33] File "C:\Python27\lib\site-packages\twisted\python\compat.py", line 68, in inet_pton [00:02:33] raise ValueError("Illegal characters: %r" % (''.join(x),)) [00:02:33] ValueError: Illegal characters: 't' ``` With `socket.AF_INET`, `socket.inet_pton(socket.AF_INET, 'localhost')` raises `socket.error` as expected. For comparison, with Python 2.7.10 running on OS X, both AF_INET and AF_INET6 raise `socket.error`. | ||
msg314815 - (view) | Author: Vitaly Kruglikov (vitaly.krug) | Date: 2018-04-02 17:27 |
This behavior goes against the socket documentation https://docs.python.org/2/library/socket.html which states "Supported values for address_family are currently AF_INET and AF_INET6. If the IP address string ip_string is invalid, *socket.error* will be raised." | ||
msg314820 - (view) | Author: Zachary Ware (zach.ware) * ![]() |
Date: 2018-04-02 18:11 |
Your traceback seems to include both pika and twisted, and as best I can tell, `socket.inet_pton` does not exist on Windows in Python 2.7. If I've diagnosed this incorrectly, please reopen the ticket with a reproducer that does not depend on pika or twisted. | ||
msg314822 - (view) | Author: Vitaly Kruglikov (vitaly.krug) | Date: 2018-04-02 18:57 |
Zachary, thank you for noticing that Twisted is involved. inet_pton definitely exists on Windows 2.7.14, but it turns out that Twisted monkey-patches it if `socket.inet_pton(socket.AF_INET6, "::")` fails. Aha! - but this suggests that Window's Python 2.7.14 implementation of `socket.inet_pton()` has a bug in that it fails to recognize '::' as the the IPv6 unspecified address 0:0:0:0:0:0:0:0, so `socket.inet_pton(socket.AF_INET6, "::")` fails. I wonder if this exists on Windows Python3 implementations? | ||
msg314833 - (view) | Author: Vitaly Kruglikov (vitaly.krug) | Date: 2018-04-02 22:28 |
Indeed, confirmed no `inet_pton()` on Windows in Python 2.7 :(. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:58:59 | admin | set | github: 77387 |
2018-04-02 22:28:14 | vitaly.krug | set | messages: + |
2018-04-02 18:57:42 | vitaly.krug | set | messages: + |
2018-04-02 18:11:36 | zach.ware | set | status: open -> closedresolution: third partymessages: + stage: resolved |
2018-04-02 17:27:12 | vitaly.krug | set | messages: + |
2018-04-02 17🔞22 | vitaly.krug | set | type: behavior |
2018-04-02 17🔞03 | vitaly.krug | create |