bpo-43908: Mark ssl, hash, and hmac types as immutable (GH-25792)
Signed-off-by: Christian Heimes <christian@python.org>
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index a515d3a..ad2ed69 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -926,6 +926,15 @@ def test_hash_disallow_instanciation(self):
):
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):