mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Include SHAKE algorithm names in HASHXOF repr (#7132)
This commit is contained in:
1
Lib/test/test_hashlib.py
vendored
1
Lib/test/test_hashlib.py
vendored
@@ -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)
|
||||
|
||||
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user