From 82b0fe5251ed3ce2349447b6391bb068a214b886 Mon Sep 17 00:00:00 2001 From: Lee Dogeon Date: Sat, 14 Feb 2026 19:11:52 +0900 Subject: [PATCH] Make HASH/HASHXOF types immutable --- 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 cd9cbe9bff7..9bb9c3bc925 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -994,8 +994,6 @@ def test_hash_disallow_instantiation(self): 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 c9902eff60a..dee02270b91 100644 --- a/crates/stdlib/src/hashlib.rs +++ b/crates/stdlib/src/hashlib.rs @@ -103,7 +103,7 @@ pub mod _hashlib { } } - #[pyclass(with(Representable))] + #[pyclass(with(Representable), flags(IMMUTABLETYPE))] impl PyHasher { fn new(name: &str, d: HashWrapper) -> Self { Self { @@ -176,7 +176,7 @@ pub mod _hashlib { } } - #[pyclass] + #[pyclass(flags(IMMUTABLETYPE))] impl PyHasherXof { fn new(name: &str, d: HashXofWrapper) -> Self { Self {