Skip to content
Open
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
6 changes: 6 additions & 0 deletions Lib/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5518,6 +5518,12 @@ def test_keylog_defaults(self):
with self.assertRaises(TypeError):
ctx.keylog_filename = 1

ctx.keylog_filename = os_helper.TESTFN
with self.assertRaisesRegex(AttributeError, 'cannot be deleted'):
del ctx.keylog_filename
# a failed deletion does not change the value
self.assertEqual(ctx.keylog_filename, os_helper.TESTFN)

def test_keylog_filename(self):
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
client_context, server_context, hostname = testing_context()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix a crash when deleting the ``keylog_filename`` attribute of
:class:`ssl.SSLContext`.
It now raises :exc:`AttributeError`.
6 changes: 6 additions & 0 deletions Modules/_ssl/debughelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ static int
_PySSLContext_set_keylog_filename(PyObject *op, PyObject *arg,
void *Py_UNUSED(closure))
{
if (arg == NULL) {
PyErr_Format(PyExc_AttributeError,
"attribute 'keylog_filename' of '%.100s' objects "
"cannot be deleted", Py_TYPE(op)->tp_name);
return -1;
}
#if defined(MS_WINDOWS_APP) && !defined(MS_WINDOWS_DESKTOP)
PyErr_SetString(PyExc_NotImplementedError,
"set_keylog_filename: unavailable on UWP build");
Expand Down
Loading