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:
Christian Heimes 2021-05-02 09:47:45 +02:00 committed by GitHub
parent fd0bc7e7f4
commit 91554e4c5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 49 additions and 18 deletions

View file

@ -926,6 +926,15 @@ class HashLibTestCase(unittest.TestCase):
):
HASHXOF()
def test_readonly_types(self):
for algorithm, constructors in self.constructors_to_test.items():
# all other types have DISALLOW_INSTANTIATION
for constructor in constructors:
hash_type = type(constructor())
with self.subTest(hash_type=hash_type):
with self.assertRaisesRegex(TypeError, "immutable type"):
hash_type.value = False
class KDFTests(unittest.TestCase):