diff --git a/Misc/NEWS.d/next/Library/2022-06-22-11-16-11.gh-issue-94101.V9vDG8.rst b/Misc/NEWS.d/next/Library/2022-06-22-11-16-11.gh-issue-94101.V9vDG8.rst new file mode 100644 index 00000000000000..bcef0ca07470a6 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-06-22-11-16-11.gh-issue-94101.V9vDG8.rst @@ -0,0 +1,3 @@ +Manual instantiation of :class:`ssl.SSLSession` objects is no longer allowed +as it lead to misconfigured instances that crashed the interpreter when +attributes where accessed on them. diff --git a/Modules/_ssl.c b/Modules/_ssl.c index af2520432a64e7..c8500c57aee757 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -5067,7 +5067,8 @@ static PyType_Spec PySSLSession_spec = { .name = "_ssl.SSLSession", .basicsize = sizeof(PySSLSession), .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_IMMUTABLETYPE), + Py_TPFLAGS_IMMUTABLETYPE | + Py_TPFLAGS_DISALLOW_INSTANTIATION), .slots = PySSLSession_slots, };