diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2020-12-27 12:46:59 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2020-12-27 12:46:59 -0500 |
commit | a78f0158a28734f965218b834ea8c0b166b7353f (patch) | |
tree | dca70268e2a41d49658e7eed783c6fc243d119cd /Modules/socketmodule.c | |
parent | ec8e6895a3ce9cd69b6ceb75a15fcc74d4a522dc (diff) | |
parent | bf64d9064ab641b1ef9a0c4bda097ebf1204faf4 (diff) | |
download | cpython-git-revert-23107-revert-13893-fix-issue-37193.tar.gz |
Merge branch 'master' into revert-23107-revert-13893-fix-issue-37193revert-23107-revert-13893-fix-issue-37193
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r-- | Modules/socketmodule.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index d773836702..bb33db0fa4 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. @@ -3366,8 +3365,9 @@ sock_getsockname(PySocketSockObject *s, PyObject *Py_UNUSED(ignored)) PyDoc_STRVAR(getsockname_doc, "getsockname() -> address info\n\ \n\ -Return the address of the local endpoint. For IP sockets, the address\n\ -info is a pair (hostaddr, port)."); +Return the address of the local endpoint. The format depends on the\n\ +address family. For IPv4 sockets, the address info is a pair\n\ +(hostaddr, port)."); #ifdef HAVE_GETPEERNAME /* Cray APP doesn't have this :-( */ @@ -4206,7 +4206,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 +7123,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) |