]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-126455: Disallow _ssl.SSLSocket instantiation (GH-126481) (#126486)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 6 Nov 2024 11:24:45 +0000 (12:24 +0100)
committerGitHub <noreply@github.com>
Wed, 6 Nov 2024 11:24:45 +0000 (11:24 +0000)
gh-126455: Disallow _ssl.SSLSocket instantiation (GH-126481)

Prevent creation of incomplete/invalid _ssl.SSLSocket objects when
created directly.
(cherry picked from commit b1c4ffc20573befb4db66bbbdd569b9bd13bb127)

Co-authored-by: Victor Stinner <vstinner@python.org>
Modules/_ssl.c

index db4e9c48df575cee402d1a40aefe678c6eae6d67..8993a6ccecb2139c40df5fadaf4d334b3df06f93 100644 (file)
@@ -2921,7 +2921,7 @@ static PyType_Spec PySSLSocket_spec = {
     .name = "_ssl._SSLSocket",
     .basicsize = sizeof(PySSLSocket),
     .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE |
-              Py_TPFLAGS_HAVE_GC),
+              Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_DISALLOW_INSTANTIATION),
     .slots = PySSLSocket_slots,
 };