This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Dominik Czarnota, aldwinaldwin, christian.heimes, vstinner
Date 2019-07-05.12:32:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1562329952.2.0.333574221146.issue37495@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2019-07-05 12:32:32vstinnersetrecipients: + vstinner, christian.heimes, aldwinaldwin, Dominik Czarnota
2019-07-05 12:32:32vstinnersetmessageid: <1562329952.2.0.333574221146.issue37495@roundup.psfhosted.org>
2019-07-05 12:32:32vstinnerlinkissue37495 messages
2019-07-05 12:32:32vstinnercreate