FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.13] gh-156099: Fix a crash when deleting SSLContext.keylog_filename (GH-156103) by serhiy-storchaka · Pull Request #156150 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .py  (1) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 6 additions & 0 deletions Lib/test/test_ssl.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -5146,6 +5146,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)

@requires_keylog
def test_keylog_filename(self):
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ static int
_PySSLContext_set_keylog_filename(PySSLContext *self, PyObject *arg, void *c) {
FILE *fp;

if (arg == NULL) {
PyErr_Format(PyExc_AttributeError,
"attribute 'keylog_filename' of '%.100s' objects "
"cannot be deleted", Py_TYPE(self)->tp_name);
return -1;
}
#if defined(MS_WINDOWS) && defined(_DEBUG)
PyErr_SetString(PyExc_NotImplementedError,
"set_keylog_filename: unavailable on Windows debug build");
Expand Down

Back | FazBrowse Home | New Git URL