bpo-42413: socket.timeout is now an alias of TimeoutError (GH-23413)

Signed-off-by: Christian Heimes <christian@python.org>
This commit is contained in:
Christian Heimes 2020-11-20 09:26:07 +01:00 committed by GitHub
parent 7ddbaa7a1b
commit 03c8ddd9e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 72 additions and 62 deletions

View file

@ -514,7 +514,6 @@ remove_unusable_flags(PyObject *m)
by this module (but not argument type or memory errors, etc.). */
static PyObject *socket_herror;
static PyObject *socket_gaierror;
static PyObject *socket_timeout;
/* A forward reference to the socket type object.
The sock_type variable contains pointers to various functions,
@ -886,7 +885,7 @@ sock_call_ex(PySocketSockObject *s,
if (err)
*err = SOCK_TIMEOUT_ERR;
else
PyErr_SetString(socket_timeout, "timed out");
PyErr_SetString(PyExc_TimeoutError, "timed out");
return -1;
}
@ -2880,7 +2879,7 @@ sock_settimeout(PySocketSockObject *s, PyObject *arg)
/* Blocking mode for a Python socket object means that operations
like :meth:`recv` or :meth:`sendall` will block the execution of
the current thread until they are complete or aborted with a
`socket.timeout` or `socket.error` errors. When timeout is `None`,
`TimeoutError` or `socket.error` errors. When timeout is `None`,
the underlying FD is in a blocking mode. When timeout is a positive
number, the FD is in a non-blocking mode, and socket ops are
implemented with a `select()` call.
@ -4206,7 +4205,7 @@ sock_sendall(PySocketSockObject *s, PyObject *args)
}
if (interval <= 0) {
PyErr_SetString(socket_timeout, "timed out");
PyErr_SetString(PyExc_TimeoutError, "timed out");
goto done;
}
}
@ -7123,13 +7122,10 @@ PyInit__socket(void)
return NULL;
Py_INCREF(socket_gaierror);
PyModule_AddObject(m, "gaierror", socket_gaierror);
socket_timeout = PyErr_NewException("socket.timeout",
PyExc_OSError, NULL);
if (socket_timeout == NULL)
return NULL;
PySocketModuleAPI.timeout_error = socket_timeout;
Py_INCREF(socket_timeout);
PyModule_AddObject(m, "timeout", socket_timeout);
PySocketModuleAPI.timeout_error = PyExc_TimeoutError;
PyModule_AddObjectRef(m, "timeout", PyExc_TimeoutError);
Py_INCREF((PyObject *)&sock_type);
if (PyModule_AddObject(m, "SocketType",
(PyObject *)&sock_type) != 0)