Skip to content

Commit 0523a57

Browse files
committed
fix error message for checking number of positional arguments
1 parent 40fd9c2 commit 0523a57

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

Lib/test/test_positional_only_arg.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ def f(a, b, /):
145145
with self.assertRaisesRegex(TypeError, expected):
146146
f(a=1, b=2)
147147

148-
# TODO: RUSTPYTHON
149-
@unittest.expectedFailure
150148
def test_positional_only_and_arg_invalid_calls(self):
151149
def f(a, b, /, c):
152150
pass
@@ -194,8 +192,6 @@ def f(a, b, /, c, *, d, e):
194192
with self.assertRaisesRegex(TypeError, r"f\(\) got an unexpected keyword argument 'f'"):
195193
f(1, 2, 3, d=1, e=4, f=56)
196194

197-
# TODO: RUSTPYTHON
198-
@unittest.expectedFailure
199195
def test_positional_only_invalid_calls(self):
200196
def f(a, b, /):
201197
pass
@@ -292,9 +288,6 @@ def test_module_function(self):
292288
with self.assertRaisesRegex(TypeError, r"f\(\) missing 2 required positional arguments: 'a' and 'b'"):
293289
global_pos_only_f()
294290

295-
296-
# TODO: RUSTPYTHON
297-
@unittest.expectedFailure
298291
def test_closures(self):
299292
def f(x,y):
300293
def g(x2,/,y2):

vm/src/builtins/function.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ impl PyFunction {
9999
// Check the number of positional arguments
100100
if nargs > nexpected_args {
101101
return Err(vm.new_type_error(format!(
102-
"Expected {} arguments (got: {})",
103-
nexpected_args, nargs
102+
"{}() takes {} positional arguments but {} were given",
103+
&self.code.obj_name, nexpected_args, nargs
104104
)));
105105
}
106106
}

0 commit comments

Comments
 (0)