Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0fb4c38

Browse filesBrowse files
gh-132987: Support __index__() in the ssl.SSLContext.options setter (GH-133098)
1 parent d6da680 commit 0fb4c38
Copy full SHA for 0fb4c38

File tree

Expand file treeCollapse file tree

2 files changed

+3
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+3
-7
lines changed

‎Lib/test/test_ssl.py

Copy file name to clipboardExpand all lines: Lib/test/test_ssl.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ def test_options(self):
986986
self.assertEqual(0, ctx.options & ~ssl.OP_NO_SSLv3)
987987

988988
# invalid options
989-
with self.assertRaises(OverflowError):
989+
with self.assertRaises(ValueError):
990990
ctx.options = -1
991991
with self.assertRaises(OverflowError):
992992
ctx.options = 2 ** 100

‎Modules/_ssl.c

Copy file name to clipboardExpand all lines: Modules/_ssl.c
+2-6Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.