mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Merge pull request #44754 from twangboy/win_fix_inet_pton
Fix inet_pton for Windows on Py3
This commit is contained in:
commit
a811a92b17
@ -10,6 +10,7 @@ import socket
|
|||||||
import ctypes
|
import ctypes
|
||||||
import os
|
import os
|
||||||
import ipaddress
|
import ipaddress
|
||||||
|
import salt.ext.six as six
|
||||||
|
|
||||||
|
|
||||||
class sockaddr(ctypes.Structure):
|
class sockaddr(ctypes.Structure):
|
||||||
@ -36,7 +37,7 @@ def inet_pton(address_family, ip_string):
|
|||||||
# This will catch IP Addresses such as 10.1.2
|
# This will catch IP Addresses such as 10.1.2
|
||||||
if address_family == socket.AF_INET:
|
if address_family == socket.AF_INET:
|
||||||
try:
|
try:
|
||||||
ipaddress.ip_address(ip_string.decode())
|
ipaddress.ip_address(six.u(ip_string))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise socket.error('illegal IP address string passed to inet_pton')
|
raise socket.error('illegal IP address string passed to inet_pton')
|
||||||
return socket.inet_aton(ip_string)
|
return socket.inet_aton(ip_string)
|
||||||
|
Loading…
Reference in New Issue
Block a user