diff options
author | Christian Heimes <christian@python.org> | 2020-11-20 08:26:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-20 08:26:07 (GMT) |
commit | 03c8ddd9e94c7bddf1f06cf785027b8d2bf00ff0 (patch) | |
tree | e293c334cb6fee7b5826b21e26ab3c56a2d2fd20 /Modules | |
parent | 7ddbaa7a1b3e61847ee99658be6a7268a049e302 (diff) | |
download | cpython-03c8ddd9e94c7bddf1f06cf785027b8d2bf00ff0.zip cpython-03c8ddd9e94c7bddf1f06cf785027b8d2bf00ff0.tar.gz cpython-03c8ddd9e94c7bddf1f06cf785027b8d2bf00ff0.tar.bz2 |
bpo-42413: socket.timeout is now an alias of TimeoutError (GH-23413)
Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ssl.c | 12 | ||||
-rw-r--r-- | Modules/socketmodule.c | 18 |
2 files changed, 13 insertions, 17 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 54c365b..a34313b 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -1102,7 +1102,7 @@ _ssl__SSLSocket_do_handshake_impl(PySSLSocket *self) } if (sockstate == SOCKET_HAS_TIMED_OUT) { - PyErr_SetString(PySocketModule.timeout_error, + PyErr_SetString(PyExc_TimeoutError, ERRSTR("The handshake operation timed out")); goto error; } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) { @@ -2419,7 +2419,7 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b) sockstate = PySSL_select(sock, 1, timeout); if (sockstate == SOCKET_HAS_TIMED_OUT) { - PyErr_SetString(PySocketModule.timeout_error, + PyErr_SetString(PyExc_TimeoutError, "The write operation timed out"); goto error; } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) { @@ -2454,7 +2454,7 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b) } if (sockstate == SOCKET_HAS_TIMED_OUT) { - PyErr_SetString(PySocketModule.timeout_error, + PyErr_SetString(PyExc_TimeoutError, "The write operation timed out"); goto error; } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) { @@ -2609,7 +2609,7 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, int len, int group_right_1, sockstate = SOCKET_OPERATION_OK; if (sockstate == SOCKET_HAS_TIMED_OUT) { - PyErr_SetString(PySocketModule.timeout_error, + PyErr_SetString(PyExc_TimeoutError, "The read operation timed out"); goto error; } else if (sockstate == SOCKET_IS_NONBLOCKING) { @@ -2724,10 +2724,10 @@ _ssl__SSLSocket_shutdown_impl(PySSLSocket *self) if (sockstate == SOCKET_HAS_TIMED_OUT) { if (err.ssl == SSL_ERROR_WANT_READ) - PyErr_SetString(PySocketModule.timeout_error, + PyErr_SetString(PyExc_TimeoutError, "The read operation timed out"); else - PyErr_SetString(PySocketModule.timeout_error, + PyErr_SetString(PyExc_TimeoutError, "The write operation timed out"); goto error; } diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index d773836..f8e4de5 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -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) |