Fix the argument parsing TypeError message

- parens are already added by the _LOCATION at call site
- fix plural-"s" logic
This commit is contained in:
Georg Brandl 2019-04-17 21:10:08 +02:00 committed by kngwyu
parent 4d7ca3a450
commit faaf1777e4
1 changed files with 2 additions and 3 deletions

View File

@ -46,11 +46,10 @@ pub fn parse_fn_args<'p>(
let nkeywords = kwargs.map_or(0, PyDict::len);
if !accept_args && !accept_kwargs && (nargs + nkeywords > params.len()) {
return Err(TypeError::py_err(format!(
"{}{} takes at most {} argument{} ({} given)",
"{} takes at most {} argument{} ({} given)",
fname.unwrap_or("function"),
if fname.is_some() { "()" } else { "" },
params.len(),
if params.len() == 1 { "s" } else { "" },
if params.len() == 1 { "" } else { "s" },
nargs + nkeywords
)));
}