Correct binascii.unhexlify error type (#4005)

* Correct `binascii.unhexlify` error type

* Unmark resolved tests
This commit is contained in:
Lee Dogeon authored and GitHub committed 2022-08-07 06:21:35 +09:00
1 parent eb9a5fac2a
commit 02e05e489d
3 files changed
+5 -6

No files matched your search

-2
View File
@@ -369,8 +369,6 @@ class BaseXYTestCase(unittest.TestCase):
b'0102ABCDEF')
self.check_encode_type_errors(base64.b16encode)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_b16decode(self):
eq = self.assertEqual
eq(base64.b16decode(b'0102ABCDEF'), b'\x01\x02\xab\xcd\xef')
-2
View File
@@ -234,8 +234,6 @@ class BinASCIITest(unittest.TestCase):
decoded = binascii.rledecode_hqx(encoded)
self.assertEqual(decoded, data)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_hex(self):
# test hexlification
s = b'{s\005\000\000\000worldi\002\000\000\000s\005\000\000\000helloi\001\000\000\0000'
+5 -2
View File
@@ -60,7 +60,7 @@ mod decl {
fn unhexlify(data: ArgAsciiBuffer, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
data.with_ref(|hex_bytes| {
if hex_bytes.len() % 2 != 0 {
return Err(vm.new_value_error("Odd-length string".to_owned()));
return Err(new_binascii_error("Odd-length string".to_owned(), vm));
}
let mut unhex = Vec::<u8>::with_capacity(hex_bytes.len() / 2);
@@ -68,7 +68,10 @@ mod decl {
if let (Some(n1), Some(n2)) = (unhex_nibble(*n1), unhex_nibble(*n2)) {
unhex.push(n1 << 4 | n2);
} else {
return Err(vm.new_value_error("Non-hexadecimal digit found".to_owned()));
return Err(new_binascii_error(
"Non-hexadecimal digit found".to_owned(),
vm,
));
}
}