Skip to content

Commit 8cd4d98

Browse files
committed
Add comment to PySSL_SetError and other changes from review
1 parent c0538c5 commit 8cd4d98

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Modules/_ssl.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,9 @@ fill_and_set_sslerror(_sslmodulestate *state,
652652
PyUnicodeWriter_Discard(writer);
653653
}
654654

655+
// Set the appropriate SSL error exception.
656+
// err - error information from SSL and libc
657+
// exc - if not NULL, an exception from _debughelpers.c callback to be chained
655658
static PyObject *
656659
PySSL_SetError(PySSLSocket *sslsock, _PySSLError err, PyObject *exc,
657660
const char *filename, int lineno)
@@ -762,9 +765,7 @@ PySSL_SetError(PySSLSocket *sslsock, _PySSLError err, PyObject *exc,
762765
}
763766
fill_and_set_sslerror(state, sslsock, type, p, errstr, lineno, e);
764767
ERR_clear_error();
765-
if (exc != NULL) {
766-
_PyErr_ChainExceptions1(exc);
767-
}
768+
_PyErr_ChainExceptions1(exc); // chain any exceptions from callbacks
768769
return NULL;
769770
}
770771

@@ -3131,8 +3132,8 @@ _ssl__SSLSocket_shutdown_impl(PySSLSocket *self)
31313132
return NULL;
31323133
}
31333134
else if (exc != NULL) {
3134-
PyErr_SetRaisedException(exc);
31353135
Py_XDECREF(sock);
3136+
PyErr_SetRaisedException(exc);
31363137
return NULL;
31373138
}
31383139
if (sock)

0 commit comments

Comments
 (0)