mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-43908: Mark ssl, hash, and hmac types as immutable (GH-25792)
Signed-off-by: Christian Heimes <christian@python.org>
This commit is contained in:
parent
fd0bc7e7f4
commit
91554e4c5c
13 changed files with 49 additions and 18 deletions
|
|
@ -345,6 +345,25 @@ class BasicSocketTests(unittest.TestCase):
|
|||
ssl.OP_NO_TLSv1_2
|
||||
self.assertEqual(ssl.PROTOCOL_TLS, ssl.PROTOCOL_SSLv23)
|
||||
|
||||
def test_ssl_types(self):
|
||||
ssl_types = [
|
||||
_ssl._SSLContext,
|
||||
_ssl._SSLSocket,
|
||||
_ssl.MemoryBIO,
|
||||
_ssl.Certificate,
|
||||
_ssl.SSLSession,
|
||||
_ssl.SSLError,
|
||||
]
|
||||
for ssl_type in ssl_types:
|
||||
with self.subTest(ssl_type=ssl_type):
|
||||
with self.assertRaisesRegex(TypeError, "immutable type"):
|
||||
ssl_type.value = None
|
||||
with self.assertRaisesRegex(
|
||||
TypeError,
|
||||
"cannot create '_ssl.Certificate' instances"
|
||||
):
|
||||
_ssl.Certificate()
|
||||
|
||||
def test_private_init(self):
|
||||
with self.assertRaisesRegex(TypeError, "public constructor"):
|
||||
with socket.socket() as s:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue