mirror of https://github.com/python/cpython
gh-102192: remove redundant exception fields from ssl module socket (#102466)
This commit is contained in:
parent
61d6c110d6
commit
e108af6eca
|
@ -318,9 +318,7 @@ typedef struct {
|
||||||
* store exception information on the socket. The handshake, read, write,
|
* store exception information on the socket. The handshake, read, write,
|
||||||
* and shutdown methods check for chained exceptions.
|
* and shutdown methods check for chained exceptions.
|
||||||
*/
|
*/
|
||||||
PyObject *exc_type;
|
PyObject *exc;
|
||||||
PyObject *exc_value;
|
|
||||||
PyObject *exc_tb;
|
|
||||||
} PySSLSocket;
|
} PySSLSocket;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -564,13 +562,11 @@ fail:
|
||||||
|
|
||||||
static int
|
static int
|
||||||
PySSL_ChainExceptions(PySSLSocket *sslsock) {
|
PySSL_ChainExceptions(PySSLSocket *sslsock) {
|
||||||
if (sslsock->exc_type == NULL)
|
if (sslsock->exc == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_PyErr_ChainExceptions(sslsock->exc_type, sslsock->exc_value, sslsock->exc_tb);
|
_PyErr_ChainExceptions1(sslsock->exc);
|
||||||
sslsock->exc_type = NULL;
|
sslsock->exc = NULL;
|
||||||
sslsock->exc_value = NULL;
|
|
||||||
sslsock->exc_tb = NULL;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,9 +803,7 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
|
||||||
self->owner = NULL;
|
self->owner = NULL;
|
||||||
self->server_hostname = NULL;
|
self->server_hostname = NULL;
|
||||||
self->err = err;
|
self->err = err;
|
||||||
self->exc_type = NULL;
|
self->exc = NULL;
|
||||||
self->exc_value = NULL;
|
|
||||||
self->exc_tb = NULL;
|
|
||||||
|
|
||||||
/* Make sure the SSL error state is initialized */
|
/* Make sure the SSL error state is initialized */
|
||||||
ERR_clear_error();
|
ERR_clear_error();
|
||||||
|
@ -2179,9 +2173,7 @@ Passed as \"self\" in servername callback.");
|
||||||
static int
|
static int
|
||||||
PySSL_traverse(PySSLSocket *self, visitproc visit, void *arg)
|
PySSL_traverse(PySSLSocket *self, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
Py_VISIT(self->exc_type);
|
Py_VISIT(self->exc);
|
||||||
Py_VISIT(self->exc_value);
|
|
||||||
Py_VISIT(self->exc_tb);
|
|
||||||
Py_VISIT(Py_TYPE(self));
|
Py_VISIT(Py_TYPE(self));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2189,9 +2181,7 @@ PySSL_traverse(PySSLSocket *self, visitproc visit, void *arg)
|
||||||
static int
|
static int
|
||||||
PySSL_clear(PySSLSocket *self)
|
PySSL_clear(PySSLSocket *self)
|
||||||
{
|
{
|
||||||
Py_CLEAR(self->exc_type);
|
Py_CLEAR(self->exc);
|
||||||
Py_CLEAR(self->exc_value);
|
|
||||||
Py_CLEAR(self->exc_tb);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2536,7 +2526,7 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, Py_ssize_t len,
|
||||||
PySSL_SetError(self, retval, __FILE__, __LINE__);
|
PySSL_SetError(self, retval, __FILE__, __LINE__);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (self->exc_type != NULL)
|
if (self->exc != NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
@ -2662,7 +2652,7 @@ _ssl__SSLSocket_shutdown_impl(PySSLSocket *self)
|
||||||
PySSL_SetError(self, ret, __FILE__, __LINE__);
|
PySSL_SetError(self, ret, __FILE__, __LINE__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (self->exc_type != NULL)
|
if (self->exc != NULL)
|
||||||
goto error;
|
goto error;
|
||||||
if (sock)
|
if (sock)
|
||||||
/* It's already INCREF'ed */
|
/* It's already INCREF'ed */
|
||||||
|
|
|
@ -74,7 +74,7 @@ _PySSL_msg_callback(int write_p, int version, int content_type,
|
||||||
buf, len
|
buf, len
|
||||||
);
|
);
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
PyErr_Fetch(&ssl_obj->exc_type, &ssl_obj->exc_value, &ssl_obj->exc_tb);
|
ssl_obj->exc = PyErr_GetRaisedException();
|
||||||
} else {
|
} else {
|
||||||
Py_DECREF(res);
|
Py_DECREF(res);
|
||||||
}
|
}
|
||||||
|
@ -138,8 +138,7 @@ _PySSL_keylog_callback(const SSL *ssl, const char *line)
|
||||||
lock = PyThread_allocate_lock();
|
lock = PyThread_allocate_lock();
|
||||||
if (lock == NULL) {
|
if (lock == NULL) {
|
||||||
PyErr_SetString(PyExc_MemoryError, "Unable to allocate lock");
|
PyErr_SetString(PyExc_MemoryError, "Unable to allocate lock");
|
||||||
PyErr_Fetch(&ssl_obj->exc_type, &ssl_obj->exc_value,
|
ssl_obj->exc = PyErr_GetRaisedException();
|
||||||
&ssl_obj->exc_tb);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +155,7 @@ _PySSL_keylog_callback(const SSL *ssl, const char *line)
|
||||||
errno = e;
|
errno = e;
|
||||||
PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError,
|
PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError,
|
||||||
ssl_obj->ctx->keylog_filename);
|
ssl_obj->ctx->keylog_filename);
|
||||||
PyErr_Fetch(&ssl_obj->exc_type, &ssl_obj->exc_value, &ssl_obj->exc_tb);
|
ssl_obj->exc = PyErr_GetRaisedException();
|
||||||
}
|
}
|
||||||
PyGILState_Release(threadstate);
|
PyGILState_Release(threadstate);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue