Skip to content

Commit 0629e37

Browse files
committed
Include SHAKE algorithm names in HASHXOF repr
1 parent 2a20860 commit 0629e37

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Lib/test/test_hashlib.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,6 @@ def test_blocksize_name(self):
462462
self.check_blocksize_name('sha384', 128, 48)
463463
self.check_blocksize_name('sha512', 128, 64)
464464

465-
# TODO: RUSTPYTHON
466-
@unittest.expectedFailure
467465
@requires_sha3
468466
def test_blocksize_name_sha3(self):
469467
self.check_blocksize_name('sha3_224', 144, 28)

crates/stdlib/src/hashlib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub mod _hashlib {
183183
}
184184
}
185185

186-
#[pyclass(flags(IMMUTABLETYPE))]
186+
#[pyclass(with(Representable), flags(IMMUTABLETYPE))]
187187
impl PyHasherXof {
188188
fn new(name: &str, d: HashXofWrapper) -> Self {
189189
Self {
@@ -233,6 +233,15 @@ pub mod _hashlib {
233233
}
234234
}
235235

236+
impl Representable for PyHasherXof {
237+
fn repr_str(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<String> {
238+
Ok(format!(
239+
"<{} _hashlib.HASHXOF object @ {:#x}>",
240+
zelf.name, zelf as *const _ as usize
241+
))
242+
}
243+
}
244+
236245
#[pyfunction(name = "new")]
237246
fn hashlib_new(args: NewHashArgs, vm: &VirtualMachine) -> PyResult<PyObjectRef> {
238247
match args.name.as_str().to_lowercase().as_str() {

0 commit comments

Comments
 (0)