From 2a2086014c634f2b265dc94059eb09bf41a6ef82 Mon Sep 17 00:00:00 2001 From: Lee Dogeon Date: Sat, 14 Feb 2026 20:37:47 +0900 Subject: [PATCH] Make HASH/HASHXOF types immutable (#7131) --- Lib/test/test_hashlib.py | 2 -- crates/stdlib/src/hashlib.rs | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index f3a5e1d49..a8d78efaf 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -992,8 +992,6 @@ class HashLibTestCase(unittest.TestCase): support.check_disallow_instantiation(self, HASH) support.check_disallow_instantiation(self, HASHXOF) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_readonly_types(self): for algorithm, constructors in self.constructors_to_test.items(): # all other types have DISALLOW_INSTANTIATION diff --git a/crates/stdlib/src/hashlib.rs b/crates/stdlib/src/hashlib.rs index db0acc232..68119e7e1 100644 --- a/crates/stdlib/src/hashlib.rs +++ b/crates/stdlib/src/hashlib.rs @@ -110,7 +110,7 @@ pub mod _hashlib { } } - #[pyclass(with(Representable))] + #[pyclass(with(Representable), flags(IMMUTABLETYPE))] impl PyHasher { fn new(name: &str, d: HashWrapper) -> Self { Self { @@ -183,7 +183,7 @@ pub mod _hashlib { } } - #[pyclass] + #[pyclass(flags(IMMUTABLETYPE))] impl PyHasherXof { fn new(name: &str, d: HashXofWrapper) -> Self { Self {