Include SHAKE algorithm names in HASHXOF repr (#7132)

This commit is contained in:
Lee Dogeon
2026-02-15 09:05:42 +09:00
committed by GitHub
parent c1a327d38b
commit cf21e2da10
2 changed files with 10 additions and 2 deletions

View File

@@ -557,7 +557,6 @@ class HashLibTestCase(unittest.TestCase):
self.check_blocksize_name('sha384', 128, 48)
self.check_blocksize_name('sha512', 128, 64)
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: 'shake' not found in '<_hashlib.hashxof object at 0xc68a2c800>'
@requires_sha3
def test_blocksize_name_sha3(self):
self.check_blocksize_name('sha3_224', 144, 28)

View File

@@ -371,7 +371,7 @@ pub mod _hashlib {
}
}
#[pyclass(flags(IMMUTABLETYPE))]
#[pyclass(with(Representable), flags(IMMUTABLETYPE))]
impl PyHasherXof {
fn new(name: &str, d: HashXofWrapper) -> Self {
Self {
@@ -447,6 +447,15 @@ pub mod _hashlib {
}
}
impl Representable for PyHasherXof {
fn repr_str(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<String> {
Ok(format!(
"<{} _hashlib.HASHXOF object @ {:#x}>",
zelf.name, zelf as *const _ as usize
))
}
}
#[pyfunction(name = "new")]
fn hashlib_new(args: NewHashArgs, vm: &VirtualMachine) -> PyResult<PyObjectRef> {
let data = resolve_data(args.data, args.string, vm)?;