STINNER Victor <vstin...@redhat.com> added the comment:
One solution would to be reimplement socket.inet_aton() with inet_pton() internally. inet_pton() is well specified and standard (POSIX). inet_aton() is not ("inet_aton() is not specified in POSIX.1, but is available on most systems." says its Linux manual page). >>> socket.inet_pton(socket.AF_INET, "1.2.3.4") b'\x01\x02\x03\x04' >>> socket.inet_pton(socket.AF_INET, "1.2.3.4 extra string") Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: illegal IP address string passed to inet_pton Problems: * inet_pton() requires an address family. Should we iterate on all supported address families until one works? * inet_pton() doesn't accept IPv4 "short format" like "127" >>> socket.inet_aton("127") b'\x00\x00\x00\x7f' >>> socket.inet_pton(socket.AF_INET, "127") Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: illegal IP address string passed to inet_pton ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37495> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com