Convert exception_from_error_queue() macros into a single function. Besides code maintainability, this makes our fast path shorter for better cache performance.
diff --git a/src/ssl/connection.c b/src/ssl/connection.c
index a5fdc51..e10989b 100755
--- a/src/ssl/connection.c
+++ b/src/ssl/connection.c
@@ -164,7 +164,7 @@
* the code which triggered the error also kindly pushed something onto
* the error stack.
*/
- exception_from_error_queue();
+ exception_from_error_queue(ssl_Error);
}
}
@@ -238,7 +238,7 @@
case SSL_ERROR_SSL:
;
default:
- exception_from_error_queue();
+ exception_from_error_queue(ssl_Error);
break;
}
}
@@ -788,7 +788,7 @@
if (ret < 0)
{
- exception_from_error_queue();
+ exception_from_error_queue(ssl_Error);
return NULL;
}
else if (ret > 0)
diff --git a/src/ssl/context.c b/src/ssl/context.c
index ae669d0..df7411f 100644
--- a/src/ssl/context.c
+++ b/src/ssl/context.c
@@ -265,7 +265,7 @@
if (!SSL_CTX_load_verify_locations(self->ctx, cafile, capath))
{
- exception_from_error_queue();
+ exception_from_error_queue(ssl_Error);
return NULL;
}
else
@@ -291,7 +291,7 @@
* -exarkun
*/
if (!SSL_CTX_set_default_verify_paths(self->ctx)) {
- exception_from_error_queue();
+ exception_from_error_queue(ssl_Error);
return NULL;
}
Py_INCREF(Py_None);
@@ -388,14 +388,14 @@
}
if (!(cert_original = X509_dup(cert->x509)))
{
- /* exception_from_error_queue(); */
+ /* exception_from_error_queue(ssl_Error); */
PyErr_SetString(PyExc_RuntimeError, "X509_dup failed");
return NULL;
}
if (!SSL_CTX_add_extra_chain_cert(self->ctx, cert_original))
{
X509_free(cert_original);
- exception_from_error_queue();
+ exception_from_error_queue(ssl_Error);
return NULL;
}
else
@@ -422,7 +422,7 @@
if (!SSL_CTX_use_certificate_chain_file(self->ctx, certfile))
{
- exception_from_error_queue();
+ exception_from_error_queue(ssl_Error);
return NULL;
}
else
@@ -451,7 +451,7 @@
if (!SSL_CTX_use_certificate_file(self->ctx, certfile, filetype))
{
- exception_from_error_queue();
+ exception_from_error_queue(ssl_Error);
return NULL;
}
else
@@ -478,7 +478,7 @@
if (!SSL_CTX_use_certificate(self->ctx, cert->x509))
{
- exception_from_error_queue();
+ exception_from_error_queue(ssl_Error);
return NULL;
}
else
@@ -516,7 +516,7 @@
if (!ret)
{
- exception_from_error_queue();
+ exception_from_error_queue(ssl_Error);
return NULL;
}
else
@@ -565,7 +565,7 @@
if (!SSL_CTX_use_PrivateKey(self->ctx, pkey->pkey))
{
- exception_from_error_queue();
+ exception_from_error_queue(ssl_Error);
return NULL;
}
else
@@ -588,7 +588,7 @@
if (!SSL_CTX_check_private_key(self->ctx))
{
- exception_from_error_queue();
+ exception_from_error_queue(ssl_Error);
return NULL;
}
else
@@ -637,7 +637,7 @@
if (!SSL_CTX_set_session_id_context(self->ctx, buf, len))
{
- exception_from_error_queue();
+ exception_from_error_queue(ssl_Error);
return NULL;
}
else
@@ -779,7 +779,7 @@
if (!SSL_CTX_set_cipher_list(self->ctx, cipher_list))
{
- exception_from_error_queue();
+ exception_from_error_queue(ssl_Error);
return NULL;
}
else
diff --git a/src/ssl/ssl.h b/src/ssl/ssl.h
index 9cf0186..ba7ba8b 100644
--- a/src/ssl/ssl.h
+++ b/src/ssl/ssl.h
@@ -27,15 +27,6 @@
*ssl_WantX509LookupError, /* ... */
*ssl_SysCallError; /* Uses (errno,errstr) */
-#ifdef exception_from_error_queue
-# undef exception_from_error_queue
-#endif
-#define exception_from_error_queue() do { \
- PyObject *errlist = error_queue_to_list(); \
- PyErr_SetObject(ssl_Error, errlist); \
- Py_DECREF(errlist); \
-} while (0)
-
#define ssl_Context_New_NUM 0
#define ssl_Context_New_RETURN ssl_ContextObj *
#define ssl_Context_New_PROTO (int method)