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

gh-132987: Support __index__() in the ssl.SSLContext.options setter #133098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 Lib/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ def test_options(self):
self.assertEqual(0, ctx.options & ~ssl.OP_NO_SSLv3)

# invalid options
with self.assertRaises(OverflowError):
with self.assertRaises(ValueError):
ctx.options = -1
with self.assertRaises(OverflowError):
ctx.options = 2 ** 100
Expand Down
8 changes: 2 additions & 6 deletions 8 Modules/_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "Python.h"
#include "pycore_fileutils.h" // _PyIsSelectable_fd()
#include "pycore_long.h" // _PyLong_UnsignedLongLong_Converter()
#include "pycore_pyerrors.h" // _PyErr_ChainExceptions1()
#include "pycore_time.h" // _PyDeadline_Init()

Expand Down Expand Up @@ -3812,19 +3813,14 @@ static int
_ssl__SSLContext_options_set_impl(PySSLContext *self, PyObject *value)
/*[clinic end generated code: output=92ca34731ece5dbb input=2b94bf789e9ae5dd]*/
{
PyObject *new_opts_obj;
unsigned long long new_opts_arg;
uint64_t new_opts, opts, clear, set;
uint64_t opt_no = (
SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 |
SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2 | SSL_OP_NO_TLSv1_3
);

if (!PyArg_Parse(value, "O!", &PyLong_Type, &new_opts_obj)) {
return -1;
}
new_opts_arg = PyLong_AsUnsignedLongLong(new_opts_obj);
if (new_opts_arg == (unsigned long long)-1 && PyErr_Occurred()) {
if (!PyArg_Parse(value, "O&", _PyLong_UnsignedLongLong_Converter, &new_opts_arg)) {
return -1;
}
Py_BUILD_ASSERT(sizeof(new_opts) >= sizeof(new_opts_arg));
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.