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

Method into_exception

crates/vm/src/function/argument.rs:325–350  ·  view source on GitHub ↗
(
        self,
        arity: RangeInclusive<usize>,
        num_given: usize,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

323
324impl ArgumentError {
325 fn into_exception(
326 self,
327 arity: RangeInclusive<usize>,
328 num_given: usize,
329 vm: &VirtualMachine,
330 ) -> PyBaseExceptionRef {
331 match self {
332 Self::TooFewArgs => vm.new_type_error(format!(
333 "expected at least {} arguments, got {}",
334 arity.start(),
335 num_given
336 )),
337 Self::TooManyArgs => vm.new_type_error(format!(
338 "expected at most {} arguments, got {}",
339 arity.end(),
340 num_given
341 )),
342 Self::InvalidKeywordArgument(name) => {
343 vm.new_type_error(format!("{name} is an invalid keyword argument"))
344 }
345 Self::RequiredKeywordArgument(name) => {
346 vm.new_type_error(format!("Required keyword only argument {name}"))
347 }
348 Self::Exception(ex) => ex,
349 }
350 }
351}
352
353/// Implemented by any type that can be accepted as a parameter to a built-in

Callers 1

bindMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected