mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Correct binascii.unhexlify error type (#4005)
* Correct `binascii.unhexlify` error type * Unmark resolved tests
This commit is contained in:
1 parent
eb9a5fac2a
commit
02e05e489d
3 files changed
+5
-6
No files matched your search
Vendored
-2
@@ -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')
|
||||
|
||||
Vendored
-2
@@ -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'
|
||||
|
||||
@@ -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,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user