@@ -39,7 +39,7 @@ def getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0):
39
39
"""Given a hostname and a port name, return a 'socket.getaddrinfo'
40
40
compatible list of tuples. Honestly, we ignore anything but host & port"""
41
41
if not isinstance (port , int ):
42
- raise RuntimeError ("Port must be an integer" )
42
+ raise ValueError ("Port must be an integer" )
43
43
ipaddr = _the_interface .get_host_by_name (host )
44
44
return [(AF_INET , socktype , proto , "" , (ipaddr , port ))]
45
45
@@ -56,7 +56,7 @@ def __init__(
56
56
self , family = AF_INET , type = SOCK_STREAM , proto = 0 , fileno = None , socknum = None
57
57
):
58
58
if family != AF_INET :
59
- raise RuntimeError ("Only AF_INET family supported" )
59
+ raise ValueError ("Only AF_INET family supported" )
60
60
self ._type = type
61
61
self ._buffer = b""
62
62
self ._socknum = socknum if socknum else _the_interface .get_socket ()
@@ -74,7 +74,7 @@ def connect(self, address, conntype=None):
74
74
if not _the_interface .socket_connect (
75
75
self ._socknum , host , port , conn_mode = conntype
76
76
):
77
- raise RuntimeError ("Failed to connect to host" , host )
77
+ raise ConnectionError ("Failed to connect to host" , host )
78
78
self ._buffer = b""
79
79
80
80
def send (self , data ): # pylint: disable=no-self-use
@@ -105,7 +105,7 @@ def readline(self, eol=b"\r\n"):
105
105
self ._buffer += _the_interface .socket_read (self ._socknum , avail )
106
106
elif self ._timeout > 0 and time .monotonic () - stamp > self ._timeout :
107
107
self .close () # Make sure to close socket so that we don't exhaust sockets.
108
- raise RuntimeError ("Didn't receive full response, failing out" )
108
+ raise OSError ("Didn't receive full response, failing out" )
109
109
firstline , self ._buffer = self ._buffer .split (eol , 1 )
110
110
gc .collect ()
111
111
return firstline
0 commit comments