]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-126455: Disallow _ssl.SSLSocket instantiation (#126481)
authorVictor Stinner <vstinner@python.org>
Wed, 6 Nov 2024 10:59:39 +0000 (11:59 +0100)
committerGitHub <noreply@github.com>
Wed, 6 Nov 2024 10:59:39 +0000 (11:59 +0100)
Prevent creation of incomplete/invalid _ssl.SSLSocket objects when
created directly.

Modules/_ssl.c

index 5223e21b5cdb11f99a71cd3f663a8e1ae49baa58..b6b5ebf094c938afb62fb0318301271a64897a1d 100644 (file)
@@ -2979,7 +2979,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,
 };