Skip to content

Commit 1db46f7

Browse files
gh-132987: Support __index__() in the ssl.SSLContext.options setter
1 parent b739ec5 commit 1db46f7

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

Modules/_ssl.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include "Python.h"
2929
#include "pycore_fileutils.h" // _PyIsSelectable_fd()
30+
#include "pycore_long.h" // _PyLong_UnsignedLongLong_Converter()
3031
#include "pycore_pyerrors.h" // _PyErr_ChainExceptions1()
3132
#include "pycore_time.h" // _PyDeadline_Init()
3233

@@ -3812,19 +3813,14 @@ static int
38123813
_ssl__SSLContext_options_set_impl(PySSLContext *self, PyObject *value)
38133814
/*[clinic end generated code: output=92ca34731ece5dbb input=2b94bf789e9ae5dd]*/
38143815
{
3815-
PyObject *new_opts_obj;
38163816
unsigned long long new_opts_arg;
38173817
uint64_t new_opts, opts, clear, set;
38183818
uint64_t opt_no = (
38193819
SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 |
38203820
SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2 | SSL_OP_NO_TLSv1_3
38213821
);
38223822

3823-
if (!PyArg_Parse(value, "O!", &PyLong_Type, &new_opts_obj)) {
3824-
return -1;
3825-
}
3826-
new_opts_arg = PyLong_AsUnsignedLongLong(new_opts_obj);
3827-
if (new_opts_arg == (unsigned long long)-1 && PyErr_Occurred()) {
3823+
if (!PyArg_Parse(value, "O&", _PyLong_UnsignedLongLong_Converter, &new_opts_arg)) {
38283824
return -1;
38293825
}
38303826
Py_BUILD_ASSERT(sizeof(new_opts) >= sizeof(new_opts_arg));

0 commit comments

Comments
 (0)