MCPcopy Index your code
hub / github.com/RustPython/RustPython / to_pyexception

Method to_pyexception

crates/stdlib/src/binascii.rs:856–873  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

854
855impl ToPyException for Base64DecodeError {
856 fn to_pyexception(&self, vm: &VirtualMachine) -> PyBaseExceptionRef {
857 use base64::DecodeError::*;
858 let message = match &self.0 {
859 InvalidByte(0, PAD) => "Leading padding not allowed".to_owned(),
860 InvalidByte(_, PAD) => "Discontinuous padding not allowed".to_owned(),
861 InvalidByte(_, _) => "Only base64 data is allowed".to_owned(),
862 InvalidLastSymbol(_, PAD) => "Excess data after padding".to_owned(),
863 InvalidLastSymbol(length, _) => {
864 format!(
865 "Invalid base64-encoded string: number of data characters {length} cannot be 1 more than a multiple of 4"
866 )
867 }
868 // TODO: clean up errors
869 InvalidLength(_) => "Incorrect padding".to_owned(),
870 InvalidPadding => "Incorrect padding".to_owned(),
871 };
872 new_binascii_error(format!("error decoding base64: {message}"), vm)
873 }
874}

Callers 15

strcollFunction · 0.45
strxfrmFunction · 0.45
setlocaleFunction · 0.45
a2b_base64Function · 0.45
convert_ssl_errorFunction · 0.45
enum_certificatesFunction · 0.45
seedMethod · 0.45
selectFunction · 0.45
getrusageFunction · 0.45
setrlimitFunction · 0.45
py_newMethod · 0.45
flushMethod · 0.45

Calls 2

new_binascii_errorFunction · 0.85
to_ownedMethod · 0.45

Tested by

no test coverage detected