diff --git a/vm/src/stdlib/binascii.rs b/vm/src/stdlib/binascii.rs index ef61b1086..8eb128d65 100644 --- a/vm/src/stdlib/binascii.rs +++ b/vm/src/stdlib/binascii.rs @@ -143,4 +143,32 @@ mod decl { } encoded } + + #[pyfunction] + fn a2b_uu(s: SerializedData, vm: &VirtualMachine) -> PyResult> { + s.with_ref(|b| { + let mut buf; + let b = if memchr::memchr(b'\n', b).is_some() { + buf = b.to_vec(); + buf.retain(|c| *c != b'\n'); + &buf + } else { + b + }; + // TODO: RUSTPYTHON, implement actual uuencoding code + base64::decode(b) + }) + .map_err(|err| vm.new_value_error(format!("error decoding uuencode: {}", err))) + } + + #[pyfunction] + fn b2a_uu(data: ArgBytesLike, NewlineArg { newline }: NewlineArg) -> Vec { + #[allow(clippy::redundant_closure)] // https://stackoverflow.com/questions/63916821 + // TODO: RUSTPYTHON, implement actual uuencoding code + let mut encoded = data.with_ref(|b| base64::encode(b)).into_bytes(); + if newline { + encoded.push(b'\n'); + } + encoded + } }