Issue #16717: get rid of socket.error, replace with OSError
This commit is contained in:
parent
ad28c7f9da
commit
0832af6628
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
:mod:`nntplib` --- NNTP protocol client
|
:mod:`nntplib` --- NNTP protocol client
|
||||||
=======================================
|
=======================================
|
||||||
|
|
||||||
|
@ -71,7 +70,7 @@ The module itself defines the following classes:
|
||||||
reader-specific commands, such as ``group``. If you get unexpected
|
reader-specific commands, such as ``group``. If you get unexpected
|
||||||
:exc:`NNTPPermanentError`\ s, you might need to set *readermode*.
|
:exc:`NNTPPermanentError`\ s, you might need to set *readermode*.
|
||||||
:class:`NNTP` class supports the :keyword:`with` statement to
|
:class:`NNTP` class supports the :keyword:`with` statement to
|
||||||
unconditionally consume :exc:`socket.error` exceptions and to close the NNTP
|
unconditionally consume :exc:`OSError` exceptions and to close the NNTP
|
||||||
connection when done. Here is a sample on how using it:
|
connection when done. Here is a sample on how using it:
|
||||||
|
|
||||||
>>> from nntplib import NNTP
|
>>> from nntplib import NNTP
|
||||||
|
|
|
@ -114,7 +114,7 @@ class async_chat (asyncore.dispatcher):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = self.recv (self.ac_in_buffer_size)
|
data = self.recv (self.ac_in_buffer_size)
|
||||||
except socket.error as why:
|
except OSError as why:
|
||||||
self.handle_error()
|
self.handle_error()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ class async_chat (asyncore.dispatcher):
|
||||||
# send the data
|
# send the data
|
||||||
try:
|
try:
|
||||||
num_sent = self.send(data)
|
num_sent = self.send(data)
|
||||||
except socket.error:
|
except OSError:
|
||||||
self.handle_error()
|
self.handle_error()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ def readwrite(obj, flags):
|
||||||
obj.handle_expt_event()
|
obj.handle_expt_event()
|
||||||
if flags & (select.POLLHUP | select.POLLERR | select.POLLNVAL):
|
if flags & (select.POLLHUP | select.POLLERR | select.POLLNVAL):
|
||||||
obj.handle_close()
|
obj.handle_close()
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
if e.args[0] not in _DISCONNECTED:
|
if e.args[0] not in _DISCONNECTED:
|
||||||
obj.handle_error()
|
obj.handle_error()
|
||||||
else:
|
else:
|
||||||
|
@ -240,7 +240,7 @@ class dispatcher:
|
||||||
# passed be connected.
|
# passed be connected.
|
||||||
try:
|
try:
|
||||||
self.addr = sock.getpeername()
|
self.addr = sock.getpeername()
|
||||||
except socket.error as err:
|
except OSError as err:
|
||||||
if err.args[0] in (ENOTCONN, EINVAL):
|
if err.args[0] in (ENOTCONN, EINVAL):
|
||||||
# To handle the case where we got an unconnected
|
# To handle the case where we got an unconnected
|
||||||
# socket.
|
# socket.
|
||||||
|
@ -304,7 +304,7 @@ class dispatcher:
|
||||||
self.socket.getsockopt(socket.SOL_SOCKET,
|
self.socket.getsockopt(socket.SOL_SOCKET,
|
||||||
socket.SO_REUSEADDR) | 1
|
socket.SO_REUSEADDR) | 1
|
||||||
)
|
)
|
||||||
except socket.error:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# ==================================================
|
# ==================================================
|
||||||
|
@ -345,7 +345,7 @@ class dispatcher:
|
||||||
self.addr = address
|
self.addr = address
|
||||||
self.handle_connect_event()
|
self.handle_connect_event()
|
||||||
else:
|
else:
|
||||||
raise socket.error(err, errorcode[err])
|
raise OSError(err, errorcode[err])
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
# XXX can return either an address pair or None
|
# XXX can return either an address pair or None
|
||||||
|
@ -353,7 +353,7 @@ class dispatcher:
|
||||||
conn, addr = self.socket.accept()
|
conn, addr = self.socket.accept()
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return None
|
return None
|
||||||
except socket.error as why:
|
except OSError as why:
|
||||||
if why.args[0] in (EWOULDBLOCK, ECONNABORTED, EAGAIN):
|
if why.args[0] in (EWOULDBLOCK, ECONNABORTED, EAGAIN):
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
|
@ -365,7 +365,7 @@ class dispatcher:
|
||||||
try:
|
try:
|
||||||
result = self.socket.send(data)
|
result = self.socket.send(data)
|
||||||
return result
|
return result
|
||||||
except socket.error as why:
|
except OSError as why:
|
||||||
if why.args[0] == EWOULDBLOCK:
|
if why.args[0] == EWOULDBLOCK:
|
||||||
return 0
|
return 0
|
||||||
elif why.args[0] in _DISCONNECTED:
|
elif why.args[0] in _DISCONNECTED:
|
||||||
|
@ -384,7 +384,7 @@ class dispatcher:
|
||||||
return b''
|
return b''
|
||||||
else:
|
else:
|
||||||
return data
|
return data
|
||||||
except socket.error as why:
|
except OSError as why:
|
||||||
# winsock sometimes raises ENOTCONN
|
# winsock sometimes raises ENOTCONN
|
||||||
if why.args[0] in _DISCONNECTED:
|
if why.args[0] in _DISCONNECTED:
|
||||||
self.handle_close()
|
self.handle_close()
|
||||||
|
@ -399,7 +399,7 @@ class dispatcher:
|
||||||
self.del_channel()
|
self.del_channel()
|
||||||
try:
|
try:
|
||||||
self.socket.close()
|
self.socket.close()
|
||||||
except socket.error as why:
|
except OSError as why:
|
||||||
if why.args[0] not in (ENOTCONN, EBADF):
|
if why.args[0] not in (ENOTCONN, EBADF):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ class dispatcher:
|
||||||
def handle_connect_event(self):
|
def handle_connect_event(self):
|
||||||
err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
|
err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
|
||||||
if err != 0:
|
if err != 0:
|
||||||
raise socket.error(err, _strerror(err))
|
raise OSError(err, _strerror(err))
|
||||||
self.handle_connect()
|
self.handle_connect()
|
||||||
self.connected = True
|
self.connected = True
|
||||||
self.connecting = False
|
self.connecting = False
|
||||||
|
|
|
@ -186,7 +186,7 @@ class upload(PyPIRCCommand):
|
||||||
http.putheader('Authorization', auth)
|
http.putheader('Authorization', auth)
|
||||||
http.endheaders()
|
http.endheaders()
|
||||||
http.send(body)
|
http.send(body)
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
self.announce(str(e), log.ERROR)
|
self.announce(str(e), log.ERROR)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ class FTP:
|
||||||
if self.sock is not None:
|
if self.sock is not None:
|
||||||
try:
|
try:
|
||||||
self.quit()
|
self.quit()
|
||||||
except (socket.error, EOFError):
|
except (OSError, EOFError):
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
if self.sock is not None:
|
if self.sock is not None:
|
||||||
|
@ -295,7 +295,7 @@ class FTP:
|
||||||
try:
|
try:
|
||||||
sock = socket.socket(af, socktype, proto)
|
sock = socket.socket(af, socktype, proto)
|
||||||
sock.bind(sa)
|
sock.bind(sa)
|
||||||
except socket.error as _:
|
except OSError as _:
|
||||||
err = _
|
err = _
|
||||||
if sock:
|
if sock:
|
||||||
sock.close()
|
sock.close()
|
||||||
|
@ -306,8 +306,8 @@ class FTP:
|
||||||
if err is not None:
|
if err is not None:
|
||||||
raise err
|
raise err
|
||||||
else:
|
else:
|
||||||
raise socket.error("getaddrinfo returns an empty list")
|
raise OSError("getaddrinfo returns an empty list")
|
||||||
raise socket.error(msg)
|
raise OSError(msg)
|
||||||
sock.listen(1)
|
sock.listen(1)
|
||||||
port = sock.getsockname()[1] # Get proper port
|
port = sock.getsockname()[1] # Get proper port
|
||||||
host = self.sock.getsockname()[0] # Get proper host
|
host = self.sock.getsockname()[0] # Get proper host
|
||||||
|
|
|
@ -791,8 +791,8 @@ class HTTPConnection:
|
||||||
|
|
||||||
if code != 200:
|
if code != 200:
|
||||||
self.close()
|
self.close()
|
||||||
raise socket.error("Tunnel connection failed: %d %s" % (code,
|
raise OSError("Tunnel connection failed: %d %s" % (code,
|
||||||
message.strip()))
|
message.strip()))
|
||||||
while True:
|
while True:
|
||||||
line = response.fp.readline(_MAXLINE + 1)
|
line = response.fp.readline(_MAXLINE + 1)
|
||||||
if len(line) > _MAXLINE:
|
if len(line) > _MAXLINE:
|
||||||
|
|
|
@ -393,7 +393,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
||||||
try:
|
try:
|
||||||
self.rpcclt = MyRPCClient(addr)
|
self.rpcclt = MyRPCClient(addr)
|
||||||
break
|
break
|
||||||
except socket.error as err:
|
except OSError as err:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.display_port_binding_error()
|
self.display_port_binding_error()
|
||||||
|
|
|
@ -199,7 +199,7 @@ class SocketIO(object):
|
||||||
raise
|
raise
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise
|
raise
|
||||||
except socket.error:
|
except OSError:
|
||||||
raise
|
raise
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
return ("CALLEXC", ex)
|
return ("CALLEXC", ex)
|
||||||
|
@ -340,7 +340,7 @@ class SocketIO(object):
|
||||||
n = self.sock.send(s[:BUFSIZE])
|
n = self.sock.send(s[:BUFSIZE])
|
||||||
except (AttributeError, TypeError):
|
except (AttributeError, TypeError):
|
||||||
raise IOError("socket no longer exists")
|
raise IOError("socket no longer exists")
|
||||||
except socket.error:
|
except OSError:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
s = s[n:]
|
s = s[n:]
|
||||||
|
@ -357,7 +357,7 @@ class SocketIO(object):
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
s = self.sock.recv(BUFSIZE)
|
s = self.sock.recv(BUFSIZE)
|
||||||
except socket.error:
|
except OSError:
|
||||||
raise EOFError
|
raise EOFError
|
||||||
if len(s) == 0:
|
if len(s) == 0:
|
||||||
raise EOFError
|
raise EOFError
|
||||||
|
@ -537,7 +537,7 @@ class RPCClient(SocketIO):
|
||||||
SocketIO.__init__(self, working_sock)
|
SocketIO.__init__(self, working_sock)
|
||||||
else:
|
else:
|
||||||
print("** Invalid host: ", address, file=sys.__stderr__)
|
print("** Invalid host: ", address, file=sys.__stderr__)
|
||||||
raise socket.error
|
raise OSError
|
||||||
|
|
||||||
def get_remote_proxy(self, oid):
|
def get_remote_proxy(self, oid):
|
||||||
return RPCProxy(self, oid)
|
return RPCProxy(self, oid)
|
||||||
|
|
|
@ -135,8 +135,8 @@ def manage_socket(address):
|
||||||
try:
|
try:
|
||||||
server = MyRPCServer(address, MyHandler)
|
server = MyRPCServer(address, MyHandler)
|
||||||
break
|
break
|
||||||
except socket.error as err:
|
except OSError as err:
|
||||||
print("IDLE Subprocess: socket error: " + err.args[1] +
|
print("IDLE Subprocess: OSError: " + err.args[1] +
|
||||||
", retrying....", file=sys.__stderr__)
|
", retrying....", file=sys.__stderr__)
|
||||||
socket_error = err
|
socket_error = err
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -174,7 +174,7 @@ class IMAP4:
|
||||||
except Exception:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
self.shutdown()
|
self.shutdown()
|
||||||
except socket.error:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ class IMAP4:
|
||||||
self.file.close()
|
self.file.close()
|
||||||
try:
|
try:
|
||||||
self.sock.shutdown(socket.SHUT_RDWR)
|
self.sock.shutdown(socket.SHUT_RDWR)
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
# The server might already have closed the connection
|
# The server might already have closed the connection
|
||||||
if e.errno != errno.ENOTCONN:
|
if e.errno != errno.ENOTCONN:
|
||||||
raise
|
raise
|
||||||
|
@ -899,7 +899,7 @@ class IMAP4:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.send(data + CRLF)
|
self.send(data + CRLF)
|
||||||
except (socket.error, OSError) as val:
|
except OSError as val:
|
||||||
raise self.abort('socket error: %s' % val)
|
raise self.abort('socket error: %s' % val)
|
||||||
|
|
||||||
if literal is None:
|
if literal is None:
|
||||||
|
@ -924,7 +924,7 @@ class IMAP4:
|
||||||
try:
|
try:
|
||||||
self.send(literal)
|
self.send(literal)
|
||||||
self.send(CRLF)
|
self.send(CRLF)
|
||||||
except (socket.error, OSError) as val:
|
except OSError as val:
|
||||||
raise self.abort('socket error: %s' % val)
|
raise self.abort('socket error: %s' % val)
|
||||||
|
|
||||||
if not literator:
|
if not literator:
|
||||||
|
|
|
@ -844,7 +844,7 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT, verify=None):
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
if self.server.ready:
|
if self.server.ready:
|
||||||
self.server.ready.set()
|
self.server.ready.set()
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
if not isinstance(e.args, tuple):
|
if not isinstance(e.args, tuple):
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -514,7 +514,7 @@ class SocketHandler(logging.Handler):
|
||||||
try:
|
try:
|
||||||
self.sock = self.makeSocket()
|
self.sock = self.makeSocket()
|
||||||
self.retryTime = None # next time, no delay before trying
|
self.retryTime = None # next time, no delay before trying
|
||||||
except socket.error:
|
except OSError:
|
||||||
#Creation failed, so set the retry time and return.
|
#Creation failed, so set the retry time and return.
|
||||||
if self.retryTime is None:
|
if self.retryTime is None:
|
||||||
self.retryPeriod = self.retryStart
|
self.retryPeriod = self.retryStart
|
||||||
|
@ -539,7 +539,7 @@ class SocketHandler(logging.Handler):
|
||||||
if self.sock:
|
if self.sock:
|
||||||
try:
|
try:
|
||||||
self.sock.sendall(s)
|
self.sock.sendall(s)
|
||||||
except socket.error: #pragma: no cover
|
except OSError: #pragma: no cover
|
||||||
self.sock.close()
|
self.sock.close()
|
||||||
self.sock = None # so we can call createSocket next time
|
self.sock = None # so we can call createSocket next time
|
||||||
|
|
||||||
|
@ -775,7 +775,7 @@ class SysLogHandler(logging.Handler):
|
||||||
self.socket = socket.socket(socket.AF_UNIX, self.socktype)
|
self.socket = socket.socket(socket.AF_UNIX, self.socktype)
|
||||||
try:
|
try:
|
||||||
self.socket.connect(address)
|
self.socket.connect(address)
|
||||||
except socket.error:
|
except OSError:
|
||||||
self.socket.close()
|
self.socket.close()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -842,7 +842,7 @@ class SysLogHandler(logging.Handler):
|
||||||
if self.unixsocket:
|
if self.unixsocket:
|
||||||
try:
|
try:
|
||||||
self.socket.send(msg)
|
self.socket.send(msg)
|
||||||
except socket.error:
|
except OSError:
|
||||||
self._connect_unixsocket(self.address)
|
self._connect_unixsocket(self.address)
|
||||||
self.socket.send(msg)
|
self.socket.send(msg)
|
||||||
elif self.socktype == socket.SOCK_DGRAM:
|
elif self.socktype == socket.SOCK_DGRAM:
|
||||||
|
|
|
@ -359,7 +359,7 @@ class _NNTPBase:
|
||||||
if is_connected():
|
if is_connected():
|
||||||
try:
|
try:
|
||||||
self.quit()
|
self.quit()
|
||||||
except (socket.error, EOFError):
|
except (OSError, EOFError):
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
if is_connected():
|
if is_connected():
|
||||||
|
|
|
@ -882,7 +882,7 @@ def _node(default=''):
|
||||||
return default
|
return default
|
||||||
try:
|
try:
|
||||||
return socket.gethostname()
|
return socket.gethostname()
|
||||||
except socket.error:
|
except OSError:
|
||||||
# Still not working...
|
# Still not working...
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ class POP3:
|
||||||
if self.sock is not None:
|
if self.sock is not None:
|
||||||
try:
|
try:
|
||||||
self.sock.shutdown(socket.SHUT_RDWR)
|
self.sock.shutdown(socket.SHUT_RDWR)
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
# The server might already have closed the connection
|
# The server might already have closed the connection
|
||||||
if e.errno != errno.ENOTCONN:
|
if e.errno != errno.ENOTCONN:
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -137,7 +137,7 @@ class SMTPChannel(asynchat.async_chat):
|
||||||
self.num_bytes = 0
|
self.num_bytes = 0
|
||||||
try:
|
try:
|
||||||
self.peer = conn.getpeername()
|
self.peer = conn.getpeername()
|
||||||
except socket.error as err:
|
except OSError as err:
|
||||||
# a race condition may occur if the other end is closing
|
# a race condition may occur if the other end is closing
|
||||||
# before we can get the peername
|
# before we can get the peername
|
||||||
self.close()
|
self.close()
|
||||||
|
@ -668,7 +668,7 @@ class PureProxy(SMTPServer):
|
||||||
except smtplib.SMTPRecipientsRefused as e:
|
except smtplib.SMTPRecipientsRefused as e:
|
||||||
print('got SMTPRecipientsRefused', file=DEBUGSTREAM)
|
print('got SMTPRecipientsRefused', file=DEBUGSTREAM)
|
||||||
refused = e.recipients
|
refused = e.recipients
|
||||||
except (socket.error, smtplib.SMTPException) as e:
|
except (OSError, smtplib.SMTPException) as e:
|
||||||
print('got', e.__class__, file=DEBUGSTREAM)
|
print('got', e.__class__, file=DEBUGSTREAM)
|
||||||
# All recipients were refused. If the exception had an associated
|
# All recipients were refused. If the exception had an associated
|
||||||
# error code, use it. Otherwise,fake it with a non-triggering
|
# error code, use it. Otherwise,fake it with a non-triggering
|
||||||
|
|
|
@ -299,7 +299,7 @@ class BaseServer:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
request, client_address = self.get_request()
|
request, client_address = self.get_request()
|
||||||
except socket.error:
|
except OSError:
|
||||||
return
|
return
|
||||||
if self.verify_request(request, client_address):
|
if self.verify_request(request, client_address):
|
||||||
try:
|
try:
|
||||||
|
@ -479,7 +479,7 @@ class TCPServer(BaseServer):
|
||||||
#explicitly shutdown. socket.close() merely releases
|
#explicitly shutdown. socket.close() merely releases
|
||||||
#the socket and waits for GC to perform the actual close.
|
#the socket and waits for GC to perform the actual close.
|
||||||
request.shutdown(socket.SHUT_WR)
|
request.shutdown(socket.SHUT_WR)
|
||||||
except socket.error:
|
except OSError:
|
||||||
pass #some platforms may raise ENOTCONN here
|
pass #some platforms may raise ENOTCONN here
|
||||||
self.close_request(request)
|
self.close_request(request)
|
||||||
|
|
||||||
|
|
10
Lib/ssl.py
10
Lib/ssl.py
|
@ -109,12 +109,14 @@ else:
|
||||||
_PROTOCOL_NAMES[PROTOCOL_SSLv2] = "SSLv2"
|
_PROTOCOL_NAMES[PROTOCOL_SSLv2] = "SSLv2"
|
||||||
|
|
||||||
from socket import getnameinfo as _getnameinfo
|
from socket import getnameinfo as _getnameinfo
|
||||||
from socket import error as socket_error
|
|
||||||
from socket import socket, AF_INET, SOCK_STREAM, create_connection
|
from socket import socket, AF_INET, SOCK_STREAM, create_connection
|
||||||
import base64 # for DER-to-PEM translation
|
import base64 # for DER-to-PEM translation
|
||||||
import traceback
|
import traceback
|
||||||
import errno
|
import errno
|
||||||
|
|
||||||
|
|
||||||
|
socket_error = OSError # keep that public name in module namespace
|
||||||
|
|
||||||
if _ssl.HAS_TLS_UNIQUE:
|
if _ssl.HAS_TLS_UNIQUE:
|
||||||
CHANNEL_BINDING_TYPES = ['tls-unique']
|
CHANNEL_BINDING_TYPES = ['tls-unique']
|
||||||
else:
|
else:
|
||||||
|
@ -279,7 +281,7 @@ class SSLSocket(socket):
|
||||||
# see if it's connected
|
# see if it's connected
|
||||||
try:
|
try:
|
||||||
sock.getpeername()
|
sock.getpeername()
|
||||||
except socket_error as e:
|
except OSError as e:
|
||||||
if e.errno != errno.ENOTCONN:
|
if e.errno != errno.ENOTCONN:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
|
@ -305,7 +307,7 @@ class SSLSocket(socket):
|
||||||
raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
|
raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
|
||||||
self.do_handshake()
|
self.do_handshake()
|
||||||
|
|
||||||
except socket_error as x:
|
except OSError as x:
|
||||||
self.close()
|
self.close()
|
||||||
raise x
|
raise x
|
||||||
|
|
||||||
|
@ -533,7 +535,7 @@ class SSLSocket(socket):
|
||||||
self.do_handshake()
|
self.do_handshake()
|
||||||
self._connected = True
|
self._connected = True
|
||||||
return rc
|
return rc
|
||||||
except socket_error:
|
except OSError:
|
||||||
self._sslobj = None
|
self._sslobj = None
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,7 @@ class Telnet:
|
||||||
"""Write a string to the socket, doubling any IAC characters.
|
"""Write a string to the socket, doubling any IAC characters.
|
||||||
|
|
||||||
Can block if the connection is blocked. May raise
|
Can block if the connection is blocked. May raise
|
||||||
socket.error if the connection is closed.
|
OSError if the connection is closed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if IAC in buffer:
|
if IAC in buffer:
|
||||||
|
|
|
@ -35,7 +35,7 @@ class HTTPSServer(_HTTPServer):
|
||||||
try:
|
try:
|
||||||
sock, addr = self.socket.accept()
|
sock, addr = self.socket.accept()
|
||||||
sslconn = self.context.wrap_socket(sock, server_side=True)
|
sslconn = self.context.wrap_socket(sock, server_side=True)
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
# socket errors are silenced by the caller, print them here
|
# socket errors are silenced by the caller, print them here
|
||||||
if support.verbose:
|
if support.verbose:
|
||||||
sys.stderr.write("Got an error:\n%s\n" % e)
|
sys.stderr.write("Got an error:\n%s\n" % e)
|
||||||
|
|
|
@ -496,7 +496,7 @@ def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
|
||||||
the SO_REUSEADDR socket option having different semantics on Windows versus
|
the SO_REUSEADDR socket option having different semantics on Windows versus
|
||||||
Unix/Linux. On Unix, you can't have two AF_INET SOCK_STREAM sockets bind,
|
Unix/Linux. On Unix, you can't have two AF_INET SOCK_STREAM sockets bind,
|
||||||
listen and then accept connections on identical host/ports. An EADDRINUSE
|
listen and then accept connections on identical host/ports. An EADDRINUSE
|
||||||
socket.error will be raised at some point (depending on the platform and
|
OSError will be raised at some point (depending on the platform and
|
||||||
the order bind and listen were called on each socket).
|
the order bind and listen were called on each socket).
|
||||||
|
|
||||||
However, on Windows, if SO_REUSEADDR is set on the sockets, no EADDRINUSE
|
However, on Windows, if SO_REUSEADDR is set on the sockets, no EADDRINUSE
|
||||||
|
@ -570,7 +570,7 @@ def _is_ipv6_enabled():
|
||||||
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
||||||
sock.bind(('::1', 0))
|
sock.bind(('::1', 0))
|
||||||
return True
|
return True
|
||||||
except (socket.error, socket.gaierror):
|
except OSError:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
if sock:
|
if sock:
|
||||||
|
@ -1098,7 +1098,7 @@ class TransientResource(object):
|
||||||
# with the Internet connection manifest themselves as exceptions.
|
# with the Internet connection manifest themselves as exceptions.
|
||||||
# XXX deprecate these and use transient_internet() instead
|
# XXX deprecate these and use transient_internet() instead
|
||||||
time_out = TransientResource(IOError, errno=errno.ETIMEDOUT)
|
time_out = TransientResource(IOError, errno=errno.ETIMEDOUT)
|
||||||
socket_peer_reset = TransientResource(socket.error, errno=errno.ECONNRESET)
|
socket_peer_reset = TransientResource(OSError, errno=errno.ECONNRESET)
|
||||||
ioerror_peer_reset = TransientResource(IOError, errno=errno.ECONNRESET)
|
ioerror_peer_reset = TransientResource(IOError, errno=errno.ECONNRESET)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -756,7 +756,7 @@ class BaseTestAPI(unittest.TestCase):
|
||||||
s2 = asyncore.dispatcher()
|
s2 = asyncore.dispatcher()
|
||||||
s2.create_socket(self.family)
|
s2.create_socket(self.family)
|
||||||
# EADDRINUSE indicates the socket was correctly bound
|
# EADDRINUSE indicates the socket was correctly bound
|
||||||
self.assertRaises(socket.error, s2.bind, (self.addr[0], port))
|
self.assertRaises(OSError, s2.bind, (self.addr[0], port))
|
||||||
|
|
||||||
def test_set_reuse_addr(self):
|
def test_set_reuse_addr(self):
|
||||||
if HAS_UNIX_SOCKETS and self.family == socket.AF_UNIX:
|
if HAS_UNIX_SOCKETS and self.family == socket.AF_UNIX:
|
||||||
|
@ -764,7 +764,7 @@ class BaseTestAPI(unittest.TestCase):
|
||||||
sock = socket.socket(self.family)
|
sock = socket.socket(self.family)
|
||||||
try:
|
try:
|
||||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
except socket.error:
|
except OSError:
|
||||||
unittest.skip("SO_REUSEADDR not supported on this platform")
|
unittest.skip("SO_REUSEADDR not supported on this platform")
|
||||||
else:
|
else:
|
||||||
# if SO_REUSEADDR succeeded for sock we expect asyncore
|
# if SO_REUSEADDR succeeded for sock we expect asyncore
|
||||||
|
@ -797,7 +797,7 @@ class BaseTestAPI(unittest.TestCase):
|
||||||
struct.pack('ii', 1, 0))
|
struct.pack('ii', 1, 0))
|
||||||
try:
|
try:
|
||||||
s.connect(server.address)
|
s.connect(server.address)
|
||||||
except socket.error:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
s.close()
|
s.close()
|
||||||
|
|
|
@ -56,7 +56,7 @@ class TestEPoll(unittest.TestCase):
|
||||||
client.setblocking(False)
|
client.setblocking(False)
|
||||||
try:
|
try:
|
||||||
client.connect(('127.0.0.1', self.serverSocket.getsockname()[1]))
|
client.connect(('127.0.0.1', self.serverSocket.getsockname()[1]))
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
self.assertEqual(e.args[0], errno.EINPROGRESS)
|
self.assertEqual(e.args[0], errno.EINPROGRESS)
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Connect should have raised EINPROGRESS")
|
raise AssertionError("Connect should have raised EINPROGRESS")
|
||||||
|
|
|
@ -321,7 +321,7 @@ if ssl is not None:
|
||||||
elif err.args[0] == ssl.SSL_ERROR_EOF:
|
elif err.args[0] == ssl.SSL_ERROR_EOF:
|
||||||
return self.handle_close()
|
return self.handle_close()
|
||||||
raise
|
raise
|
||||||
except socket.error as err:
|
except OSError as err:
|
||||||
if err.args[0] == errno.ECONNABORTED:
|
if err.args[0] == errno.ECONNABORTED:
|
||||||
return self.handle_close()
|
return self.handle_close()
|
||||||
else:
|
else:
|
||||||
|
@ -335,7 +335,7 @@ if ssl is not None:
|
||||||
if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
|
if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
|
||||||
ssl.SSL_ERROR_WANT_WRITE):
|
ssl.SSL_ERROR_WANT_WRITE):
|
||||||
return
|
return
|
||||||
except socket.error as err:
|
except OSError as err:
|
||||||
# Any "socket error" corresponds to a SSL_ERROR_SYSCALL return
|
# Any "socket error" corresponds to a SSL_ERROR_SYSCALL return
|
||||||
# from OpenSSL's SSL_shutdown(), corresponding to a
|
# from OpenSSL's SSL_shutdown(), corresponding to a
|
||||||
# closed socket condition. See also:
|
# closed socket condition. See also:
|
||||||
|
@ -676,7 +676,7 @@ class TestFTPClass(TestCase):
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
self.client.sendcmd('noop')
|
self.client.sendcmd('noop')
|
||||||
except (socket.error, EOFError):
|
except (OSError, EOFError):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class EPipeSocket(FakeSocket):
|
||||||
|
|
||||||
def sendall(self, data):
|
def sendall(self, data):
|
||||||
if self.pipe_trigger in data:
|
if self.pipe_trigger in data:
|
||||||
raise socket.error(errno.EPIPE, "gotcha")
|
raise OSError(errno.EPIPE, "gotcha")
|
||||||
self.data += data
|
self.data += data
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
@ -515,7 +515,7 @@ class BasicTest(TestCase):
|
||||||
b"Content-Length")
|
b"Content-Length")
|
||||||
conn = client.HTTPConnection("example.com")
|
conn = client.HTTPConnection("example.com")
|
||||||
conn.sock = sock
|
conn.sock = sock
|
||||||
self.assertRaises(socket.error,
|
self.assertRaises(OSError,
|
||||||
lambda: conn.request("PUT", "/url", "body"))
|
lambda: conn.request("PUT", "/url", "body"))
|
||||||
resp = conn.getresponse()
|
resp = conn.getresponse()
|
||||||
self.assertEqual(401, resp.status)
|
self.assertEqual(401, resp.status)
|
||||||
|
|
|
@ -94,7 +94,7 @@ class TestKQueue(unittest.TestCase):
|
||||||
client.setblocking(False)
|
client.setblocking(False)
|
||||||
try:
|
try:
|
||||||
client.connect(('127.0.0.1', serverSocket.getsockname()[1]))
|
client.connect(('127.0.0.1', serverSocket.getsockname()[1]))
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
self.assertEqual(e.args[0], errno.EINPROGRESS)
|
self.assertEqual(e.args[0], errno.EINPROGRESS)
|
||||||
else:
|
else:
|
||||||
#raise AssertionError("Connect should have raised EINPROGRESS")
|
#raise AssertionError("Connect should have raised EINPROGRESS")
|
||||||
|
|
|
@ -569,7 +569,7 @@ class HandlerTest(BaseTest):
|
||||||
self.assertEqual(h.facility, h.LOG_USER)
|
self.assertEqual(h.facility, h.LOG_USER)
|
||||||
self.assertTrue(h.unixsocket)
|
self.assertTrue(h.unixsocket)
|
||||||
h.close()
|
h.close()
|
||||||
except socket.error: # syslogd might not be available
|
except OSError: # syslogd might not be available
|
||||||
pass
|
pass
|
||||||
for method in ('GET', 'POST', 'PUT'):
|
for method in ('GET', 'POST', 'PUT'):
|
||||||
if method == 'PUT':
|
if method == 'PUT':
|
||||||
|
@ -679,7 +679,7 @@ if threading:
|
||||||
self.num_bytes = 0
|
self.num_bytes = 0
|
||||||
try:
|
try:
|
||||||
self.peer = conn.getpeername()
|
self.peer = conn.getpeername()
|
||||||
except socket.error as err:
|
except OSError as err:
|
||||||
# a race condition may occur if the other end is closing
|
# a race condition may occur if the other end is closing
|
||||||
# before we can get the peername
|
# before we can get the peername
|
||||||
self.close()
|
self.close()
|
||||||
|
@ -880,7 +880,7 @@ if threading:
|
||||||
sock, addr = self.socket.accept()
|
sock, addr = self.socket.accept()
|
||||||
if self.sslctx:
|
if self.sslctx:
|
||||||
sock = self.sslctx.wrap_socket(sock, server_side=True)
|
sock = self.sslctx.wrap_socket(sock, server_side=True)
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
# socket errors are silenced by the caller, print them here
|
# socket errors are silenced by the caller, print them here
|
||||||
sys.stderr.write("Got an error:\n%s\n" % e)
|
sys.stderr.write("Got an error:\n%s\n" % e)
|
||||||
raise
|
raise
|
||||||
|
@ -946,7 +946,7 @@ if threading:
|
||||||
if data:
|
if data:
|
||||||
try:
|
try:
|
||||||
super(DelegatingUDPRequestHandler, self).finish()
|
super(DelegatingUDPRequestHandler, self).finish()
|
||||||
except socket.error:
|
except OSError:
|
||||||
if not self.server._closed:
|
if not self.server._closed:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ class NetworkedNNTPTestsMixin:
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
server.help()
|
server.help()
|
||||||
except (socket.error, EOFError):
|
except (OSError, EOFError):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ class DummyPOP3Handler(asynchat.async_chat):
|
||||||
elif err.args[0] == ssl.SSL_ERROR_EOF:
|
elif err.args[0] == ssl.SSL_ERROR_EOF:
|
||||||
return self.handle_close()
|
return self.handle_close()
|
||||||
raise
|
raise
|
||||||
except socket.error as err:
|
except OSError as err:
|
||||||
if err.args[0] == errno.ECONNABORTED:
|
if err.args[0] == errno.ECONNABORTED:
|
||||||
return self.handle_close()
|
return self.handle_close()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -535,7 +535,7 @@ class NonConnectingTests(unittest.TestCase):
|
||||||
smtp.send, 'test msg')
|
smtp.send, 'test msg')
|
||||||
|
|
||||||
def testNonnumericPort(self):
|
def testNonnumericPort(self):
|
||||||
# check that non-numeric port raises socket.error
|
# check that non-numeric port raises OSError
|
||||||
self.assertRaises(OSError, smtplib.SMTP,
|
self.assertRaises(OSError, smtplib.SMTP,
|
||||||
"localhost", "bogus")
|
"localhost", "bogus")
|
||||||
self.assertRaises(OSError, smtplib.SMTP,
|
self.assertRaises(OSError, smtplib.SMTP,
|
||||||
|
|
|
@ -46,7 +46,7 @@ def _have_socket_can():
|
||||||
"""Check whether CAN sockets are supported on this host."""
|
"""Check whether CAN sockets are supported on this host."""
|
||||||
try:
|
try:
|
||||||
s = socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW)
|
s = socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW)
|
||||||
except (AttributeError, socket.error, OSError):
|
except (AttributeError, OSError):
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
s.close()
|
s.close()
|
||||||
|
@ -126,7 +126,7 @@ class SocketCANTest(unittest.TestCase):
|
||||||
self.addCleanup(self.s.close)
|
self.addCleanup(self.s.close)
|
||||||
try:
|
try:
|
||||||
self.s.bind((self.interface,))
|
self.s.bind((self.interface,))
|
||||||
except socket.error:
|
except OSError:
|
||||||
self.skipTest('network interface `%s` does not exist' %
|
self.skipTest('network interface `%s` does not exist' %
|
||||||
self.interface)
|
self.interface)
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ class ThreadedCANSocketTest(SocketCANTest, ThreadableTest):
|
||||||
self.cli = socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW)
|
self.cli = socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW)
|
||||||
try:
|
try:
|
||||||
self.cli.bind((self.interface,))
|
self.cli.bind((self.interface,))
|
||||||
except socket.error:
|
except OSError:
|
||||||
# skipTest should not be called here, and will be called in the
|
# skipTest should not be called here, and will be called in the
|
||||||
# server instead
|
# server instead
|
||||||
pass
|
pass
|
||||||
|
@ -608,7 +608,7 @@ def requireSocket(*args):
|
||||||
for obj in args]
|
for obj in args]
|
||||||
try:
|
try:
|
||||||
s = socket.socket(*callargs)
|
s = socket.socket(*callargs)
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
# XXX: check errno?
|
# XXX: check errno?
|
||||||
err = str(e)
|
err = str(e)
|
||||||
else:
|
else:
|
||||||
|
@ -645,11 +645,11 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
def testSocketError(self):
|
def testSocketError(self):
|
||||||
# Testing socket module exceptions
|
# Testing socket module exceptions
|
||||||
msg = "Error raising socket exception (%s)."
|
msg = "Error raising socket exception (%s)."
|
||||||
with self.assertRaises(socket.error, msg=msg % 'socket.error'):
|
with self.assertRaises(OSError, msg=msg % 'OSError'):
|
||||||
raise socket.error
|
raise OSError
|
||||||
with self.assertRaises(socket.error, msg=msg % 'socket.herror'):
|
with self.assertRaises(OSError, msg=msg % 'socket.herror'):
|
||||||
raise socket.herror
|
raise socket.herror
|
||||||
with self.assertRaises(socket.error, msg=msg % 'socket.gaierror'):
|
with self.assertRaises(OSError, msg=msg % 'socket.gaierror'):
|
||||||
raise socket.gaierror
|
raise socket.gaierror
|
||||||
|
|
||||||
def testSendtoErrors(self):
|
def testSendtoErrors(self):
|
||||||
|
@ -712,13 +712,13 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
try:
|
try:
|
||||||
ip = socket.gethostbyname(hostname)
|
ip = socket.gethostbyname(hostname)
|
||||||
except socket.error:
|
except OSError:
|
||||||
# Probably name lookup wasn't set up right; skip this test
|
# Probably name lookup wasn't set up right; skip this test
|
||||||
return
|
return
|
||||||
self.assertTrue(ip.find('.') >= 0, "Error resolving host to ip.")
|
self.assertTrue(ip.find('.') >= 0, "Error resolving host to ip.")
|
||||||
try:
|
try:
|
||||||
hname, aliases, ipaddrs = socket.gethostbyaddr(ip)
|
hname, aliases, ipaddrs = socket.gethostbyaddr(ip)
|
||||||
except socket.error:
|
except OSError:
|
||||||
# Probably a similar problem as above; skip this test
|
# Probably a similar problem as above; skip this test
|
||||||
return
|
return
|
||||||
all_host_names = [hostname, hname] + aliases
|
all_host_names = [hostname, hname] + aliases
|
||||||
|
@ -732,7 +732,7 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
oldhn = socket.gethostname()
|
oldhn = socket.gethostname()
|
||||||
try:
|
try:
|
||||||
socket.sethostname('new')
|
socket.sethostname('new')
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
if e.errno == errno.EPERM:
|
if e.errno == errno.EPERM:
|
||||||
self.skipTest("test should be run as root")
|
self.skipTest("test should be run as root")
|
||||||
else:
|
else:
|
||||||
|
@ -766,8 +766,8 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
'socket.if_nameindex() not available.')
|
'socket.if_nameindex() not available.')
|
||||||
def testInvalidInterfaceNameIndex(self):
|
def testInvalidInterfaceNameIndex(self):
|
||||||
# test nonexistent interface index/name
|
# test nonexistent interface index/name
|
||||||
self.assertRaises(socket.error, socket.if_indextoname, 0)
|
self.assertRaises(OSError, socket.if_indextoname, 0)
|
||||||
self.assertRaises(socket.error, socket.if_nametoindex, '_DEADBEEF')
|
self.assertRaises(OSError, socket.if_nametoindex, '_DEADBEEF')
|
||||||
# test with invalid values
|
# test with invalid values
|
||||||
self.assertRaises(TypeError, socket.if_nametoindex, 0)
|
self.assertRaises(TypeError, socket.if_nametoindex, 0)
|
||||||
self.assertRaises(TypeError, socket.if_indextoname, '_DEADBEEF')
|
self.assertRaises(TypeError, socket.if_indextoname, '_DEADBEEF')
|
||||||
|
@ -788,7 +788,7 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
# On some versions, this crashes the interpreter.
|
# On some versions, this crashes the interpreter.
|
||||||
socket.getnameinfo(('x', 0, 0, 0), 0)
|
socket.getnameinfo(('x', 0, 0, 0), 0)
|
||||||
except socket.error:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def testNtoH(self):
|
def testNtoH(self):
|
||||||
|
@ -835,17 +835,17 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
port = socket.getservbyname(service, 'tcp')
|
port = socket.getservbyname(service, 'tcp')
|
||||||
break
|
break
|
||||||
except socket.error:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise socket.error
|
raise OSError
|
||||||
# Try same call with optional protocol omitted
|
# Try same call with optional protocol omitted
|
||||||
port2 = socket.getservbyname(service)
|
port2 = socket.getservbyname(service)
|
||||||
eq(port, port2)
|
eq(port, port2)
|
||||||
# Try udp, but don't barf it it doesn't exist
|
# Try udp, but don't barf it it doesn't exist
|
||||||
try:
|
try:
|
||||||
udpport = socket.getservbyname(service, 'udp')
|
udpport = socket.getservbyname(service, 'udp')
|
||||||
except socket.error:
|
except OSError:
|
||||||
udpport = None
|
udpport = None
|
||||||
else:
|
else:
|
||||||
eq(udpport, port)
|
eq(udpport, port)
|
||||||
|
@ -901,7 +901,7 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
g = lambda a: inet_pton(AF_INET, a)
|
g = lambda a: inet_pton(AF_INET, a)
|
||||||
|
|
||||||
assertInvalid = lambda func,a: self.assertRaises(
|
assertInvalid = lambda func,a: self.assertRaises(
|
||||||
(socket.error, ValueError), func, a
|
(OSError, ValueError), func, a
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(b'\x00\x00\x00\x00', f('0.0.0.0'))
|
self.assertEqual(b'\x00\x00\x00\x00', f('0.0.0.0'))
|
||||||
|
@ -936,7 +936,7 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
return
|
return
|
||||||
f = lambda a: inet_pton(AF_INET6, a)
|
f = lambda a: inet_pton(AF_INET6, a)
|
||||||
assertInvalid = lambda a: self.assertRaises(
|
assertInvalid = lambda a: self.assertRaises(
|
||||||
(socket.error, ValueError), f, a
|
(OSError, ValueError), f, a
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(b'\x00' * 16, f('::'))
|
self.assertEqual(b'\x00' * 16, f('::'))
|
||||||
|
@ -985,7 +985,7 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
from socket import inet_ntoa as f, inet_ntop, AF_INET
|
from socket import inet_ntoa as f, inet_ntop, AF_INET
|
||||||
g = lambda a: inet_ntop(AF_INET, a)
|
g = lambda a: inet_ntop(AF_INET, a)
|
||||||
assertInvalid = lambda func,a: self.assertRaises(
|
assertInvalid = lambda func,a: self.assertRaises(
|
||||||
(socket.error, ValueError), func, a
|
(OSError, ValueError), func, a
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual('1.0.1.0', f(b'\x01\x00\x01\x00'))
|
self.assertEqual('1.0.1.0', f(b'\x01\x00\x01\x00'))
|
||||||
|
@ -1014,7 +1014,7 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
return
|
return
|
||||||
f = lambda a: inet_ntop(AF_INET6, a)
|
f = lambda a: inet_ntop(AF_INET6, a)
|
||||||
assertInvalid = lambda a: self.assertRaises(
|
assertInvalid = lambda a: self.assertRaises(
|
||||||
(socket.error, ValueError), f, a
|
(OSError, ValueError), f, a
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual('::', f(b'\x00' * 16))
|
self.assertEqual('::', f(b'\x00' * 16))
|
||||||
|
@ -1042,7 +1042,7 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
# At least for eCos. This is required for the S/390 to pass.
|
# At least for eCos. This is required for the S/390 to pass.
|
||||||
try:
|
try:
|
||||||
my_ip_addr = socket.gethostbyname(socket.gethostname())
|
my_ip_addr = socket.gethostbyname(socket.gethostname())
|
||||||
except socket.error:
|
except OSError:
|
||||||
# Probably name lookup wasn't set up right; skip this test
|
# Probably name lookup wasn't set up right; skip this test
|
||||||
return
|
return
|
||||||
self.assertIn(name[0], ("0.0.0.0", my_ip_addr), '%s invalid' % name[0])
|
self.assertIn(name[0], ("0.0.0.0", my_ip_addr), '%s invalid' % name[0])
|
||||||
|
@ -1069,7 +1069,7 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
sock.settimeout(1)
|
sock.settimeout(1)
|
||||||
sock.close()
|
sock.close()
|
||||||
self.assertRaises(socket.error, sock.send, b"spam")
|
self.assertRaises(OSError, sock.send, b"spam")
|
||||||
|
|
||||||
def testNewAttributes(self):
|
def testNewAttributes(self):
|
||||||
# testing .family, .type and .protocol
|
# testing .family, .type and .protocol
|
||||||
|
@ -1168,7 +1168,7 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
|
|
||||||
def test_getnameinfo(self):
|
def test_getnameinfo(self):
|
||||||
# only IP addresses are allowed
|
# only IP addresses are allowed
|
||||||
self.assertRaises(socket.error, socket.getnameinfo, ('mail.python.org',0), 0)
|
self.assertRaises(OSError, socket.getnameinfo, ('mail.python.org',0), 0)
|
||||||
|
|
||||||
@unittest.skipUnless(support.is_resource_enabled('network'),
|
@unittest.skipUnless(support.is_resource_enabled('network'),
|
||||||
'network is not enabled')
|
'network is not enabled')
|
||||||
|
@ -1296,7 +1296,7 @@ class BasicCANTest(unittest.TestCase):
|
||||||
def testTooLongInterfaceName(self):
|
def testTooLongInterfaceName(self):
|
||||||
# most systems limit IFNAMSIZ to 16, take 1024 to be sure
|
# most systems limit IFNAMSIZ to 16, take 1024 to be sure
|
||||||
with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s:
|
with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s:
|
||||||
self.assertRaisesRegex(socket.error, 'interface name too long',
|
self.assertRaisesRegex(OSError, 'interface name too long',
|
||||||
s.bind, ('x' * 1024,))
|
s.bind, ('x' * 1024,))
|
||||||
|
|
||||||
@unittest.skipUnless(hasattr(socket, "CAN_RAW_LOOPBACK"),
|
@unittest.skipUnless(hasattr(socket, "CAN_RAW_LOOPBACK"),
|
||||||
|
@ -1591,7 +1591,7 @@ class BasicTCPTest(SocketConnectedTest):
|
||||||
self.assertEqual(f, fileno)
|
self.assertEqual(f, fileno)
|
||||||
# cli_conn cannot be used anymore...
|
# cli_conn cannot be used anymore...
|
||||||
self.assertTrue(self.cli_conn._closed)
|
self.assertTrue(self.cli_conn._closed)
|
||||||
self.assertRaises(socket.error, self.cli_conn.recv, 1024)
|
self.assertRaises(OSError, self.cli_conn.recv, 1024)
|
||||||
self.cli_conn.close()
|
self.cli_conn.close()
|
||||||
# ...but we can create another socket using the (still open)
|
# ...but we can create another socket using the (still open)
|
||||||
# file descriptor
|
# file descriptor
|
||||||
|
@ -1960,7 +1960,7 @@ class SendmsgTests(SendrecvmsgServerTimeoutBase):
|
||||||
def _testSendmsgExcessCmsgReject(self):
|
def _testSendmsgExcessCmsgReject(self):
|
||||||
if not hasattr(socket, "CMSG_SPACE"):
|
if not hasattr(socket, "CMSG_SPACE"):
|
||||||
# Can only send one item
|
# Can only send one item
|
||||||
with self.assertRaises(socket.error) as cm:
|
with self.assertRaises(OSError) as cm:
|
||||||
self.sendmsgToServer([MSG], [(0, 0, b""), (0, 0, b"")])
|
self.sendmsgToServer([MSG], [(0, 0, b""), (0, 0, b"")])
|
||||||
self.assertIsNone(cm.exception.errno)
|
self.assertIsNone(cm.exception.errno)
|
||||||
self.sendToServer(b"done")
|
self.sendToServer(b"done")
|
||||||
|
@ -1971,7 +1971,7 @@ class SendmsgTests(SendrecvmsgServerTimeoutBase):
|
||||||
|
|
||||||
def _testSendmsgAfterClose(self):
|
def _testSendmsgAfterClose(self):
|
||||||
self.cli_sock.close()
|
self.cli_sock.close()
|
||||||
self.assertRaises(socket.error, self.sendmsgToServer, [MSG])
|
self.assertRaises(OSError, self.sendmsgToServer, [MSG])
|
||||||
|
|
||||||
|
|
||||||
class SendmsgStreamTests(SendmsgTests):
|
class SendmsgStreamTests(SendmsgTests):
|
||||||
|
@ -2015,7 +2015,7 @@ class SendmsgStreamTests(SendmsgTests):
|
||||||
@testSendmsgDontWait.client_skip
|
@testSendmsgDontWait.client_skip
|
||||||
def _testSendmsgDontWait(self):
|
def _testSendmsgDontWait(self):
|
||||||
try:
|
try:
|
||||||
with self.assertRaises(socket.error) as cm:
|
with self.assertRaises(OSError) as cm:
|
||||||
while True:
|
while True:
|
||||||
self.sendmsgToServer([b"a"*512], [], socket.MSG_DONTWAIT)
|
self.sendmsgToServer([b"a"*512], [], socket.MSG_DONTWAIT)
|
||||||
self.assertIn(cm.exception.errno,
|
self.assertIn(cm.exception.errno,
|
||||||
|
@ -2035,9 +2035,9 @@ class SendmsgConnectionlessTests(SendmsgTests):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _testSendmsgNoDestAddr(self):
|
def _testSendmsgNoDestAddr(self):
|
||||||
self.assertRaises(socket.error, self.cli_sock.sendmsg,
|
self.assertRaises(OSError, self.cli_sock.sendmsg,
|
||||||
[MSG])
|
[MSG])
|
||||||
self.assertRaises(socket.error, self.cli_sock.sendmsg,
|
self.assertRaises(OSError, self.cli_sock.sendmsg,
|
||||||
[MSG], [], 0, None)
|
[MSG], [], 0, None)
|
||||||
|
|
||||||
|
|
||||||
|
@ -2123,7 +2123,7 @@ class RecvmsgGenericTests(SendrecvmsgBase):
|
||||||
def testRecvmsgAfterClose(self):
|
def testRecvmsgAfterClose(self):
|
||||||
# Check that recvmsg[_into]() fails on a closed socket.
|
# Check that recvmsg[_into]() fails on a closed socket.
|
||||||
self.serv_sock.close()
|
self.serv_sock.close()
|
||||||
self.assertRaises(socket.error, self.doRecvmsg, self.serv_sock, 1024)
|
self.assertRaises(OSError, self.doRecvmsg, self.serv_sock, 1024)
|
||||||
|
|
||||||
def _testRecvmsgAfterClose(self):
|
def _testRecvmsgAfterClose(self):
|
||||||
pass
|
pass
|
||||||
|
@ -2571,7 +2571,7 @@ class SCMRightsTest(SendrecvmsgServerTimeoutBase):
|
||||||
# call fails, just send msg with no ancillary data.
|
# call fails, just send msg with no ancillary data.
|
||||||
try:
|
try:
|
||||||
nbytes = self.sendmsgToServer([msg], ancdata)
|
nbytes = self.sendmsgToServer([msg], ancdata)
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
# Check that it was the system call that failed
|
# Check that it was the system call that failed
|
||||||
self.assertIsInstance(e.errno, int)
|
self.assertIsInstance(e.errno, int)
|
||||||
nbytes = self.sendmsgToServer([msg])
|
nbytes = self.sendmsgToServer([msg])
|
||||||
|
@ -2949,7 +2949,7 @@ class RFC3542AncillaryTest(SendrecvmsgServerTimeoutBase):
|
||||||
array.array("i", [self.traffic_class]).tobytes() + b"\x00"),
|
array.array("i", [self.traffic_class]).tobytes() + b"\x00"),
|
||||||
(socket.IPPROTO_IPV6, socket.IPV6_HOPLIMIT,
|
(socket.IPPROTO_IPV6, socket.IPV6_HOPLIMIT,
|
||||||
array.array("i", [self.hop_limit]))])
|
array.array("i", [self.hop_limit]))])
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
self.assertIsInstance(e.errno, int)
|
self.assertIsInstance(e.errno, int)
|
||||||
nbytes = self.sendmsgToServer(
|
nbytes = self.sendmsgToServer(
|
||||||
[MSG],
|
[MSG],
|
||||||
|
@ -3396,10 +3396,10 @@ class InterruptedRecvTimeoutTest(InterruptedTimeoutBase, UDPTestBase):
|
||||||
self.serv.settimeout(self.timeout)
|
self.serv.settimeout(self.timeout)
|
||||||
|
|
||||||
def checkInterruptedRecv(self, func, *args, **kwargs):
|
def checkInterruptedRecv(self, func, *args, **kwargs):
|
||||||
# Check that func(*args, **kwargs) raises socket.error with an
|
# Check that func(*args, **kwargs) raises OSError with an
|
||||||
# errno of EINTR when interrupted by a signal.
|
# errno of EINTR when interrupted by a signal.
|
||||||
self.setAlarm(self.alarm_time)
|
self.setAlarm(self.alarm_time)
|
||||||
with self.assertRaises(socket.error) as cm:
|
with self.assertRaises(OSError) as cm:
|
||||||
func(*args, **kwargs)
|
func(*args, **kwargs)
|
||||||
self.assertNotIsInstance(cm.exception, socket.timeout)
|
self.assertNotIsInstance(cm.exception, socket.timeout)
|
||||||
self.assertEqual(cm.exception.errno, errno.EINTR)
|
self.assertEqual(cm.exception.errno, errno.EINTR)
|
||||||
|
@ -3456,9 +3456,9 @@ class InterruptedSendTimeoutTest(InterruptedTimeoutBase,
|
||||||
|
|
||||||
def checkInterruptedSend(self, func, *args, **kwargs):
|
def checkInterruptedSend(self, func, *args, **kwargs):
|
||||||
# Check that func(*args, **kwargs), run in a loop, raises
|
# Check that func(*args, **kwargs), run in a loop, raises
|
||||||
# socket.error with an errno of EINTR when interrupted by a
|
# OSError with an errno of EINTR when interrupted by a
|
||||||
# signal.
|
# signal.
|
||||||
with self.assertRaises(socket.error) as cm:
|
with self.assertRaises(OSError) as cm:
|
||||||
while True:
|
while True:
|
||||||
self.setAlarm(self.alarm_time)
|
self.setAlarm(self.alarm_time)
|
||||||
func(*args, **kwargs)
|
func(*args, **kwargs)
|
||||||
|
@ -3552,7 +3552,7 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
|
||||||
start = time.time()
|
start = time.time()
|
||||||
try:
|
try:
|
||||||
self.serv.accept()
|
self.serv.accept()
|
||||||
except socket.error:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
end = time.time()
|
end = time.time()
|
||||||
self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.")
|
self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.")
|
||||||
|
@ -3573,7 +3573,7 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
|
||||||
start = time.time()
|
start = time.time()
|
||||||
try:
|
try:
|
||||||
self.serv.accept()
|
self.serv.accept()
|
||||||
except socket.error:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
end = time.time()
|
end = time.time()
|
||||||
self.assertTrue((end - start) < 1.0, "Error creating with non-blocking mode.")
|
self.assertTrue((end - start) < 1.0, "Error creating with non-blocking mode.")
|
||||||
|
@ -3603,7 +3603,7 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
|
||||||
self.serv.setblocking(0)
|
self.serv.setblocking(0)
|
||||||
try:
|
try:
|
||||||
conn, addr = self.serv.accept()
|
conn, addr = self.serv.accept()
|
||||||
except socket.error:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.fail("Error trying to do non-blocking accept.")
|
self.fail("Error trying to do non-blocking accept.")
|
||||||
|
@ -3633,7 +3633,7 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
|
||||||
conn.setblocking(0)
|
conn.setblocking(0)
|
||||||
try:
|
try:
|
||||||
msg = conn.recv(len(MSG))
|
msg = conn.recv(len(MSG))
|
||||||
except socket.error:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.fail("Error trying to do non-blocking recv.")
|
self.fail("Error trying to do non-blocking recv.")
|
||||||
|
@ -3808,7 +3808,7 @@ class FileObjectClassTestCase(SocketConnectedTest):
|
||||||
self.read_file.close()
|
self.read_file.close()
|
||||||
self.assertRaises(ValueError, self.read_file.fileno)
|
self.assertRaises(ValueError, self.read_file.fileno)
|
||||||
self.cli_conn.close()
|
self.cli_conn.close()
|
||||||
self.assertRaises(socket.error, self.cli_conn.getsockname)
|
self.assertRaises(OSError, self.cli_conn.getsockname)
|
||||||
|
|
||||||
def _testRealClose(self):
|
def _testRealClose(self):
|
||||||
pass
|
pass
|
||||||
|
@ -3845,7 +3845,7 @@ class FileObjectInterruptedTestCase(unittest.TestCase):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _raise_eintr():
|
def _raise_eintr():
|
||||||
raise socket.error(errno.EINTR, "interrupted")
|
raise OSError(errno.EINTR, "interrupted")
|
||||||
|
|
||||||
def _textiowrap_mock_socket(self, mock, buffering=-1):
|
def _textiowrap_mock_socket(self, mock, buffering=-1):
|
||||||
raw = socket.SocketIO(mock, "r")
|
raw = socket.SocketIO(mock, "r")
|
||||||
|
@ -3957,7 +3957,7 @@ class UnbufferedFileObjectClassTestCase(FileObjectClassTestCase):
|
||||||
self.assertEqual(msg, self.read_msg)
|
self.assertEqual(msg, self.read_msg)
|
||||||
# ...until the file is itself closed
|
# ...until the file is itself closed
|
||||||
self.read_file.close()
|
self.read_file.close()
|
||||||
self.assertRaises(socket.error, self.cli_conn.recv, 1024)
|
self.assertRaises(OSError, self.cli_conn.recv, 1024)
|
||||||
|
|
||||||
def _testMakefileClose(self):
|
def _testMakefileClose(self):
|
||||||
self.write_file.write(self.write_msg)
|
self.write_file.write(self.write_msg)
|
||||||
|
@ -4106,7 +4106,7 @@ class NetworkConnectionNoServer(unittest.TestCase):
|
||||||
port = support.find_unused_port()
|
port = support.find_unused_port()
|
||||||
cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
self.addCleanup(cli.close)
|
self.addCleanup(cli.close)
|
||||||
with self.assertRaises(socket.error) as cm:
|
with self.assertRaises(OSError) as cm:
|
||||||
cli.connect((HOST, port))
|
cli.connect((HOST, port))
|
||||||
self.assertEqual(cm.exception.errno, errno.ECONNREFUSED)
|
self.assertEqual(cm.exception.errno, errno.ECONNREFUSED)
|
||||||
|
|
||||||
|
@ -4114,7 +4114,7 @@ class NetworkConnectionNoServer(unittest.TestCase):
|
||||||
# Issue #9792: errors raised by create_connection() should have
|
# Issue #9792: errors raised by create_connection() should have
|
||||||
# a proper errno attribute.
|
# a proper errno attribute.
|
||||||
port = support.find_unused_port()
|
port = support.find_unused_port()
|
||||||
with self.assertRaises(socket.error) as cm:
|
with self.assertRaises(OSError) as cm:
|
||||||
socket.create_connection((HOST, port))
|
socket.create_connection((HOST, port))
|
||||||
|
|
||||||
# Issue #16257: create_connection() calls getaddrinfo() against
|
# Issue #16257: create_connection() calls getaddrinfo() against
|
||||||
|
@ -4262,7 +4262,7 @@ class TCPTimeoutTest(SocketTCPTest):
|
||||||
foo = self.serv.accept()
|
foo = self.serv.accept()
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
self.fail("caught timeout instead of error (TCP)")
|
self.fail("caught timeout instead of error (TCP)")
|
||||||
except socket.error:
|
except OSError:
|
||||||
ok = True
|
ok = True
|
||||||
except:
|
except:
|
||||||
self.fail("caught unexpected exception (TCP)")
|
self.fail("caught unexpected exception (TCP)")
|
||||||
|
@ -4319,7 +4319,7 @@ class UDPTimeoutTest(SocketUDPTest):
|
||||||
foo = self.serv.recv(1024)
|
foo = self.serv.recv(1024)
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
self.fail("caught timeout instead of error (UDP)")
|
self.fail("caught timeout instead of error (UDP)")
|
||||||
except socket.error:
|
except OSError:
|
||||||
ok = True
|
ok = True
|
||||||
except:
|
except:
|
||||||
self.fail("caught unexpected exception (UDP)")
|
self.fail("caught unexpected exception (UDP)")
|
||||||
|
@ -4329,10 +4329,10 @@ class UDPTimeoutTest(SocketUDPTest):
|
||||||
class TestExceptions(unittest.TestCase):
|
class TestExceptions(unittest.TestCase):
|
||||||
|
|
||||||
def testExceptionTree(self):
|
def testExceptionTree(self):
|
||||||
self.assertTrue(issubclass(socket.error, Exception))
|
self.assertTrue(issubclass(OSError, Exception))
|
||||||
self.assertTrue(issubclass(socket.herror, socket.error))
|
self.assertTrue(issubclass(socket.herror, OSError))
|
||||||
self.assertTrue(issubclass(socket.gaierror, socket.error))
|
self.assertTrue(issubclass(socket.gaierror, OSError))
|
||||||
self.assertTrue(issubclass(socket.timeout, socket.error))
|
self.assertTrue(issubclass(socket.timeout, OSError))
|
||||||
|
|
||||||
class TestLinuxAbstractNamespace(unittest.TestCase):
|
class TestLinuxAbstractNamespace(unittest.TestCase):
|
||||||
|
|
||||||
|
@ -4358,7 +4358,7 @@ class TestLinuxAbstractNamespace(unittest.TestCase):
|
||||||
def testNameOverflow(self):
|
def testNameOverflow(self):
|
||||||
address = "\x00" + "h" * self.UNIX_PATH_MAX
|
address = "\x00" + "h" * self.UNIX_PATH_MAX
|
||||||
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
|
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
|
||||||
self.assertRaises(socket.error, s.bind, address)
|
self.assertRaises(OSError, s.bind, address)
|
||||||
|
|
||||||
def testStrName(self):
|
def testStrName(self):
|
||||||
# Check that an abstract name can be passed as a string.
|
# Check that an abstract name can be passed as a string.
|
||||||
|
@ -4597,7 +4597,7 @@ class ContextManagersTest(ThreadedTCPSocketTest):
|
||||||
self.assertTrue(sock._closed)
|
self.assertTrue(sock._closed)
|
||||||
# exception inside with block
|
# exception inside with block
|
||||||
with socket.socket() as sock:
|
with socket.socket() as sock:
|
||||||
self.assertRaises(socket.error, sock.sendall, b'foo')
|
self.assertRaises(OSError, sock.sendall, b'foo')
|
||||||
self.assertTrue(sock._closed)
|
self.assertTrue(sock._closed)
|
||||||
|
|
||||||
def testCreateConnectionBase(self):
|
def testCreateConnectionBase(self):
|
||||||
|
@ -4625,7 +4625,7 @@ class ContextManagersTest(ThreadedTCPSocketTest):
|
||||||
with socket.create_connection(address) as sock:
|
with socket.create_connection(address) as sock:
|
||||||
sock.close()
|
sock.close()
|
||||||
self.assertTrue(sock._closed)
|
self.assertTrue(sock._closed)
|
||||||
self.assertRaises(socket.error, sock.sendall, b'foo')
|
self.assertRaises(OSError, sock.sendall, b'foo')
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(hasattr(socket, "SOCK_CLOEXEC"),
|
@unittest.skipUnless(hasattr(socket, "SOCK_CLOEXEC"),
|
||||||
|
|
|
@ -213,15 +213,15 @@ class BasicSocketTests(unittest.TestCase):
|
||||||
|
|
||||||
def test_wrapped_unconnected(self):
|
def test_wrapped_unconnected(self):
|
||||||
# Methods on an unconnected SSLSocket propagate the original
|
# Methods on an unconnected SSLSocket propagate the original
|
||||||
# socket.error raise by the underlying socket object.
|
# OSError raise by the underlying socket object.
|
||||||
s = socket.socket(socket.AF_INET)
|
s = socket.socket(socket.AF_INET)
|
||||||
ss = ssl.wrap_socket(s)
|
ss = ssl.wrap_socket(s)
|
||||||
self.assertRaises(socket.error, ss.recv, 1)
|
self.assertRaises(OSError, ss.recv, 1)
|
||||||
self.assertRaises(socket.error, ss.recv_into, bytearray(b'x'))
|
self.assertRaises(OSError, ss.recv_into, bytearray(b'x'))
|
||||||
self.assertRaises(socket.error, ss.recvfrom, 1)
|
self.assertRaises(OSError, ss.recvfrom, 1)
|
||||||
self.assertRaises(socket.error, ss.recvfrom_into, bytearray(b'x'), 1)
|
self.assertRaises(OSError, ss.recvfrom_into, bytearray(b'x'), 1)
|
||||||
self.assertRaises(socket.error, ss.send, b'x')
|
self.assertRaises(OSError, ss.send, b'x')
|
||||||
self.assertRaises(socket.error, ss.sendto, b'x', ('0.0.0.0', 0))
|
self.assertRaises(OSError, ss.sendto, b'x', ('0.0.0.0', 0))
|
||||||
|
|
||||||
def test_timeout(self):
|
def test_timeout(self):
|
||||||
# Issue #8524: when creating an SSL socket, the timeout of the
|
# Issue #8524: when creating an SSL socket, the timeout of the
|
||||||
|
@ -1012,7 +1012,7 @@ else:
|
||||||
sys.stdout.write(" server: read %r (%s), sending back %r (%s)...\n"
|
sys.stdout.write(" server: read %r (%s), sending back %r (%s)...\n"
|
||||||
% (msg, ctype, msg.lower(), ctype))
|
% (msg, ctype, msg.lower(), ctype))
|
||||||
self.write(msg.lower())
|
self.write(msg.lower())
|
||||||
except socket.error:
|
except OSError:
|
||||||
if self.server.chatty:
|
if self.server.chatty:
|
||||||
handle_error("Test server failure:\n")
|
handle_error("Test server failure:\n")
|
||||||
self.close()
|
self.close()
|
||||||
|
@ -1122,7 +1122,7 @@ else:
|
||||||
return self.handle_close()
|
return self.handle_close()
|
||||||
except ssl.SSLError:
|
except ssl.SSLError:
|
||||||
raise
|
raise
|
||||||
except socket.error as err:
|
except OSError as err:
|
||||||
if err.args[0] == errno.ECONNABORTED:
|
if err.args[0] == errno.ECONNABORTED:
|
||||||
return self.handle_close()
|
return self.handle_close()
|
||||||
else:
|
else:
|
||||||
|
@ -1226,9 +1226,9 @@ else:
|
||||||
except ssl.SSLError as x:
|
except ssl.SSLError as x:
|
||||||
if support.verbose:
|
if support.verbose:
|
||||||
sys.stdout.write("\nSSLError is %s\n" % x.args[1])
|
sys.stdout.write("\nSSLError is %s\n" % x.args[1])
|
||||||
except socket.error as x:
|
except OSError as x:
|
||||||
if support.verbose:
|
if support.verbose:
|
||||||
sys.stdout.write("\nsocket.error is %s\n" % x.args[1])
|
sys.stdout.write("\nOSError is %s\n" % x.args[1])
|
||||||
except IOError as x:
|
except IOError as x:
|
||||||
if x.errno != errno.ENOENT:
|
if x.errno != errno.ENOENT:
|
||||||
raise
|
raise
|
||||||
|
@ -1313,7 +1313,7 @@ else:
|
||||||
except ssl.SSLError:
|
except ssl.SSLError:
|
||||||
if expect_success:
|
if expect_success:
|
||||||
raise
|
raise
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
if expect_success or e.errno != errno.ECONNRESET:
|
if expect_success or e.errno != errno.ECONNRESET:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
|
@ -1458,7 +1458,7 @@ else:
|
||||||
if hasattr(ssl, 'PROTOCOL_SSLv2'):
|
if hasattr(ssl, 'PROTOCOL_SSLv2'):
|
||||||
try:
|
try:
|
||||||
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True)
|
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True)
|
||||||
except (ssl.SSLError, socket.error) as x:
|
except OSError as x:
|
||||||
# this fails on some older versions of OpenSSL (0.9.7l, for instance)
|
# this fails on some older versions of OpenSSL (0.9.7l, for instance)
|
||||||
if support.verbose:
|
if support.verbose:
|
||||||
sys.stdout.write(
|
sys.stdout.write(
|
||||||
|
@ -1844,7 +1844,7 @@ else:
|
||||||
chatty=False) as server:
|
chatty=False) as server:
|
||||||
with socket.socket() as sock:
|
with socket.socket() as sock:
|
||||||
s = context.wrap_socket(sock)
|
s = context.wrap_socket(sock)
|
||||||
with self.assertRaises((OSError, ssl.SSLError)):
|
with self.assertRaises(OSError):
|
||||||
s.connect((HOST, server.port))
|
s.connect((HOST, server.port))
|
||||||
self.assertIn("no shared cipher", str(server.conn_errors[0]))
|
self.assertIn("no shared cipher", str(server.conn_errors[0]))
|
||||||
|
|
||||||
|
|
|
@ -344,7 +344,7 @@ class MockHTTPClass:
|
||||||
self.data = body
|
self.data = body
|
||||||
if self.raise_on_endheaders:
|
if self.raise_on_endheaders:
|
||||||
import socket
|
import socket
|
||||||
raise socket.error()
|
raise OSError()
|
||||||
def getresponse(self):
|
def getresponse(self):
|
||||||
return MockHTTPResponse(MockFile(), {}, 200, "OK")
|
return MockHTTPResponse(MockFile(), {}, 200, "OK")
|
||||||
|
|
||||||
|
@ -845,7 +845,7 @@ class HandlerTests(unittest.TestCase):
|
||||||
("Foo", "bar"), ("Spam", "eggs")])
|
("Foo", "bar"), ("Spam", "eggs")])
|
||||||
self.assertEqual(http.data, data)
|
self.assertEqual(http.data, data)
|
||||||
|
|
||||||
# check socket.error converted to URLError
|
# check OSError converted to URLError
|
||||||
http.raise_on_endheaders = True
|
http.raise_on_endheaders = True
|
||||||
self.assertRaises(urllib.error.URLError, h.do_open, http, req)
|
self.assertRaises(urllib.error.URLError, h.do_open, http, req)
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ class XMLRPCTestCase(unittest.TestCase):
|
||||||
xmlrpc.client.ServerProxy('https://localhost:9999').bad_function()
|
xmlrpc.client.ServerProxy('https://localhost:9999').bad_function()
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
self.assertFalse(has_ssl, "xmlrpc client's error with SSL support")
|
self.assertFalse(has_ssl, "xmlrpc client's error with SSL support")
|
||||||
except socket.error:
|
except OSError:
|
||||||
self.assertTrue(has_ssl)
|
self.assertTrue(has_ssl)
|
||||||
|
|
||||||
class HelperTestCase(unittest.TestCase):
|
class HelperTestCase(unittest.TestCase):
|
||||||
|
@ -492,7 +492,7 @@ def is_unavailable_exception(e):
|
||||||
return True
|
return True
|
||||||
exc_mess = e.headers.get('X-exception')
|
exc_mess = e.headers.get('X-exception')
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# Ignore socket.errors here.
|
# Ignore OSErrors here.
|
||||||
exc_mess = str(e)
|
exc_mess = str(e)
|
||||||
|
|
||||||
if exc_mess and 'temporarily unavailable' in exc_mess.lower():
|
if exc_mess and 'temporarily unavailable' in exc_mess.lower():
|
||||||
|
@ -507,7 +507,7 @@ def make_request_and_skipIf(condition, reason):
|
||||||
def make_request_and_skip(self):
|
def make_request_and_skip(self):
|
||||||
try:
|
try:
|
||||||
xmlrpclib.ServerProxy(URL).my_function()
|
xmlrpclib.ServerProxy(URL).my_function()
|
||||||
except (xmlrpclib.ProtocolError, socket.error) as e:
|
except (xmlrpclib.ProtocolError, OSError) as e:
|
||||||
if not is_unavailable_exception(e):
|
if not is_unavailable_exception(e):
|
||||||
raise
|
raise
|
||||||
raise unittest.SkipTest(reason)
|
raise unittest.SkipTest(reason)
|
||||||
|
@ -545,7 +545,7 @@ class SimpleServerTestCase(BaseServerTestCase):
|
||||||
try:
|
try:
|
||||||
p = xmlrpclib.ServerProxy(URL)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
self.assertEqual(p.pow(6,8), 6**8)
|
self.assertEqual(p.pow(6,8), 6**8)
|
||||||
except (xmlrpclib.ProtocolError, socket.error) as e:
|
except (xmlrpclib.ProtocolError, OSError) as e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
if not is_unavailable_exception(e):
|
if not is_unavailable_exception(e):
|
||||||
# protocol error; provide additional information in test output
|
# protocol error; provide additional information in test output
|
||||||
|
@ -558,7 +558,7 @@ class SimpleServerTestCase(BaseServerTestCase):
|
||||||
p = xmlrpclib.ServerProxy(URL)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
self.assertEqual(p.add(start_string, end_string),
|
self.assertEqual(p.add(start_string, end_string),
|
||||||
start_string + end_string)
|
start_string + end_string)
|
||||||
except (xmlrpclib.ProtocolError, socket.error) as e:
|
except (xmlrpclib.ProtocolError, OSError) as e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
if not is_unavailable_exception(e):
|
if not is_unavailable_exception(e):
|
||||||
# protocol error; provide additional information in test output
|
# protocol error; provide additional information in test output
|
||||||
|
@ -584,7 +584,7 @@ class SimpleServerTestCase(BaseServerTestCase):
|
||||||
p = xmlrpclib.ServerProxy(URL)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
meth = p.system.listMethods()
|
meth = p.system.listMethods()
|
||||||
self.assertEqual(set(meth), expected_methods)
|
self.assertEqual(set(meth), expected_methods)
|
||||||
except (xmlrpclib.ProtocolError, socket.error) as e:
|
except (xmlrpclib.ProtocolError, OSError) as e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
if not is_unavailable_exception(e):
|
if not is_unavailable_exception(e):
|
||||||
# protocol error; provide additional information in test output
|
# protocol error; provide additional information in test output
|
||||||
|
@ -597,7 +597,7 @@ class SimpleServerTestCase(BaseServerTestCase):
|
||||||
p = xmlrpclib.ServerProxy(URL)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
divhelp = p.system.methodHelp('div')
|
divhelp = p.system.methodHelp('div')
|
||||||
self.assertEqual(divhelp, 'This is the div function')
|
self.assertEqual(divhelp, 'This is the div function')
|
||||||
except (xmlrpclib.ProtocolError, socket.error) as e:
|
except (xmlrpclib.ProtocolError, OSError) as e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
if not is_unavailable_exception(e):
|
if not is_unavailable_exception(e):
|
||||||
# protocol error; provide additional information in test output
|
# protocol error; provide additional information in test output
|
||||||
|
@ -611,7 +611,7 @@ class SimpleServerTestCase(BaseServerTestCase):
|
||||||
p = xmlrpclib.ServerProxy(URL)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
myfunction = p.system.methodHelp('my_function')
|
myfunction = p.system.methodHelp('my_function')
|
||||||
self.assertEqual(myfunction, 'This is my function')
|
self.assertEqual(myfunction, 'This is my function')
|
||||||
except (xmlrpclib.ProtocolError, socket.error) as e:
|
except (xmlrpclib.ProtocolError, OSError) as e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
if not is_unavailable_exception(e):
|
if not is_unavailable_exception(e):
|
||||||
# protocol error; provide additional information in test output
|
# protocol error; provide additional information in test output
|
||||||
|
@ -624,7 +624,7 @@ class SimpleServerTestCase(BaseServerTestCase):
|
||||||
p = xmlrpclib.ServerProxy(URL)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
divsig = p.system.methodSignature('div')
|
divsig = p.system.methodSignature('div')
|
||||||
self.assertEqual(divsig, 'signatures not supported')
|
self.assertEqual(divsig, 'signatures not supported')
|
||||||
except (xmlrpclib.ProtocolError, socket.error) as e:
|
except (xmlrpclib.ProtocolError, OSError) as e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
if not is_unavailable_exception(e):
|
if not is_unavailable_exception(e):
|
||||||
# protocol error; provide additional information in test output
|
# protocol error; provide additional information in test output
|
||||||
|
@ -641,7 +641,7 @@ class SimpleServerTestCase(BaseServerTestCase):
|
||||||
self.assertEqual(add_result, 2+3)
|
self.assertEqual(add_result, 2+3)
|
||||||
self.assertEqual(pow_result, 6**8)
|
self.assertEqual(pow_result, 6**8)
|
||||||
self.assertEqual(div_result, 127//42)
|
self.assertEqual(div_result, 127//42)
|
||||||
except (xmlrpclib.ProtocolError, socket.error) as e:
|
except (xmlrpclib.ProtocolError, OSError) as e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
if not is_unavailable_exception(e):
|
if not is_unavailable_exception(e):
|
||||||
# protocol error; provide additional information in test output
|
# protocol error; provide additional information in test output
|
||||||
|
@ -662,7 +662,7 @@ class SimpleServerTestCase(BaseServerTestCase):
|
||||||
self.assertEqual(result.results[0]['faultString'],
|
self.assertEqual(result.results[0]['faultString'],
|
||||||
'<class \'Exception\'>:method "this_is_not_exists" '
|
'<class \'Exception\'>:method "this_is_not_exists" '
|
||||||
'is not supported')
|
'is not supported')
|
||||||
except (xmlrpclib.ProtocolError, socket.error) as e:
|
except (xmlrpclib.ProtocolError, OSError) as e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
if not is_unavailable_exception(e):
|
if not is_unavailable_exception(e):
|
||||||
# protocol error; provide additional information in test output
|
# protocol error; provide additional information in test output
|
||||||
|
@ -915,7 +915,7 @@ class FailingServerTestCase(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
p = xmlrpclib.ServerProxy(URL)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
self.assertEqual(p.pow(6,8), 6**8)
|
self.assertEqual(p.pow(6,8), 6**8)
|
||||||
except (xmlrpclib.ProtocolError, socket.error) as e:
|
except (xmlrpclib.ProtocolError, OSError) as e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
if not is_unavailable_exception(e):
|
if not is_unavailable_exception(e):
|
||||||
# protocol error; provide additional information in test output
|
# protocol error; provide additional information in test output
|
||||||
|
@ -928,7 +928,7 @@ class FailingServerTestCase(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
p = xmlrpclib.ServerProxy(URL)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
p.pow(6,8)
|
p.pow(6,8)
|
||||||
except (xmlrpclib.ProtocolError, socket.error) as e:
|
except (xmlrpclib.ProtocolError, OSError) as e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
if not is_unavailable_exception(e) and hasattr(e, "headers"):
|
if not is_unavailable_exception(e) and hasattr(e, "headers"):
|
||||||
# The two server-side error headers shouldn't be sent back in this case
|
# The two server-side error headers shouldn't be sent back in this case
|
||||||
|
@ -948,7 +948,7 @@ class FailingServerTestCase(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
p = xmlrpclib.ServerProxy(URL)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
p.pow(6,8)
|
p.pow(6,8)
|
||||||
except (xmlrpclib.ProtocolError, socket.error) as e:
|
except (xmlrpclib.ProtocolError, OSError) as e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
if not is_unavailable_exception(e) and hasattr(e, "headers"):
|
if not is_unavailable_exception(e) and hasattr(e, "headers"):
|
||||||
# We should get error info in the response
|
# We should get error info in the response
|
||||||
|
|
|
@ -18,7 +18,7 @@ class CurrentTimeTest(unittest.TestCase):
|
||||||
server = xmlrpclib.ServerProxy("http://time.xmlrpc.com/RPC2")
|
server = xmlrpclib.ServerProxy("http://time.xmlrpc.com/RPC2")
|
||||||
try:
|
try:
|
||||||
t0 = server.currentTime.getCurrentTime()
|
t0 = server.currentTime.getCurrentTime()
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
self.skipTest("network error: %s" % e)
|
self.skipTest("network error: %s" % e)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class CurrentTimeTest(unittest.TestCase):
|
||||||
server = xmlrpclib.ServerProxy("http://buildbot.python.org/all/xmlrpc/")
|
server = xmlrpclib.ServerProxy("http://buildbot.python.org/all/xmlrpc/")
|
||||||
try:
|
try:
|
||||||
builders = server.getAllBuilders()
|
builders = server.getAllBuilders()
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
self.skipTest("network error: %s" % e)
|
self.skipTest("network error: %s" % e)
|
||||||
return
|
return
|
||||||
self.addCleanup(lambda: server('close')())
|
self.addCleanup(lambda: server('close')())
|
||||||
|
|
|
@ -1275,7 +1275,7 @@ class AbstractHTTPHandler(BaseHandler):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
h.request(req.get_method(), req.selector, req.data, headers)
|
h.request(req.get_method(), req.selector, req.data, headers)
|
||||||
except socket.error as err: # timeout error
|
except OSError as err: # timeout error
|
||||||
h.close()
|
h.close()
|
||||||
raise URLError(err)
|
raise URLError(err)
|
||||||
else:
|
else:
|
||||||
|
@ -1480,7 +1480,7 @@ class FTPHandler(BaseHandler):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
host = socket.gethostbyname(host)
|
host = socket.gethostbyname(host)
|
||||||
except socket.error as msg:
|
except OSError as msg:
|
||||||
raise URLError(msg)
|
raise URLError(msg)
|
||||||
path, attrs = splitattr(req.selector)
|
path, attrs = splitattr(req.selector)
|
||||||
dirs = path.split('/')
|
dirs = path.split('/')
|
||||||
|
@ -1721,7 +1721,7 @@ class URLopener:
|
||||||
return getattr(self, name)(url, data)
|
return getattr(self, name)(url, data)
|
||||||
except (HTTPError, URLError):
|
except (HTTPError, URLError):
|
||||||
raise
|
raise
|
||||||
except socket.error as msg:
|
except OSError as msg:
|
||||||
raise IOError('socket error', msg).with_traceback(sys.exc_info()[2])
|
raise IOError('socket error', msg).with_traceback(sys.exc_info()[2])
|
||||||
|
|
||||||
def open_unknown(self, fullurl, data=None):
|
def open_unknown(self, fullurl, data=None):
|
||||||
|
@ -2487,7 +2487,7 @@ def _proxy_bypass_macosx_sysconf(host, proxy_settings):
|
||||||
try:
|
try:
|
||||||
hostIP = socket.gethostbyname(hostonly)
|
hostIP = socket.gethostbyname(hostonly)
|
||||||
hostIP = ip2num(hostIP)
|
hostIP = ip2num(hostIP)
|
||||||
except socket.error:
|
except OSError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
base = ip2num(m.group(1))
|
base = ip2num(m.group(1))
|
||||||
|
@ -2614,13 +2614,13 @@ elif os.name == 'nt':
|
||||||
addr = socket.gethostbyname(rawHost)
|
addr = socket.gethostbyname(rawHost)
|
||||||
if addr != rawHost:
|
if addr != rawHost:
|
||||||
host.append(addr)
|
host.append(addr)
|
||||||
except socket.error:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
fqdn = socket.getfqdn(rawHost)
|
fqdn = socket.getfqdn(rawHost)
|
||||||
if fqdn != rawHost:
|
if fqdn != rawHost:
|
||||||
host.append(fqdn)
|
host.append(fqdn)
|
||||||
except socket.error:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
# make a check value list from the registry entry: replace the
|
# make a check value list from the registry entry: replace the
|
||||||
# '<local>' string by the localhost entry and the corresponding
|
# '<local>' string by the localhost entry and the corresponding
|
||||||
|
|
|
@ -418,7 +418,7 @@ class Grail(BaseBrowser):
|
||||||
# need to PING each one until we find one that's live
|
# need to PING each one until we find one that's live
|
||||||
try:
|
try:
|
||||||
s.connect(fn)
|
s.connect(fn)
|
||||||
except socket.error:
|
except OSError:
|
||||||
# no good; attempt to clean it out, but don't fail:
|
# no good; attempt to clean it out, but don't fail:
|
||||||
try:
|
try:
|
||||||
os.unlink(fn)
|
os.unlink(fn)
|
||||||
|
|
|
@ -1130,8 +1130,9 @@ class Transport:
|
||||||
for i in (0, 1):
|
for i in (0, 1):
|
||||||
try:
|
try:
|
||||||
return self.single_request(host, handler, request_body, verbose)
|
return self.single_request(host, handler, request_body, verbose)
|
||||||
except socket.error as e:
|
except OSError as e:
|
||||||
if i or e.errno not in (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE):
|
if i or e.errno not in (errno.ECONNRESET, errno.ECONNABORTED,
|
||||||
|
errno.EPIPE):
|
||||||
raise
|
raise
|
||||||
except http.client.BadStatusLine: #close after we sent request
|
except http.client.BadStatusLine: #close after we sent request
|
||||||
if i:
|
if i:
|
||||||
|
|
|
@ -15,7 +15,7 @@ Limitations:
|
||||||
|
|
||||||
Module interface:
|
Module interface:
|
||||||
|
|
||||||
- socket.error: exception raised for socket specific errors
|
- socket.error: exception raised for socket specific errors, alias for OSError
|
||||||
- socket.gaierror: exception raised for getaddrinfo/getnameinfo errors,
|
- socket.gaierror: exception raised for getaddrinfo/getnameinfo errors,
|
||||||
a subclass of socket.error
|
a subclass of socket.error
|
||||||
- socket.herror: exception raised for gethostby* errors,
|
- socket.herror: exception raised for gethostby* errors,
|
||||||
|
|
Loading…
Reference in New Issue