Message347337
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 |
|
Date |
User |
Action |
Args |
2019-07-05 12:32:32 | vstinner | set | recipients:
+ vstinner, christian.heimes, aldwinaldwin, Dominik Czarnota |
2019-07-05 12:32:32 | vstinner | set | messageid: <1562329952.2.0.333574221146.issue37495@roundup.psfhosted.org> |
2019-07-05 12:32:32 | vstinner | link | issue37495 messages |
2019-07-05 12:32:32 | vstinner | create | |
|