* Name the function a failed argument binding was binding for
A built-in call that binds badly reported neither the function nor, for a
method, the right numbers: `self` was prepended before binding, so it was
counted as both an expected parameter and a given argument. `[].append()`
read `expected at least 2 arguments, got 1`.
`Callee` carries what a message says about the function: the name, and
whether the leading argument fills the instance parameter. `PyNativeFn`
takes one, `PyNativeFunction` and `PyMethodDescriptor` supply it, and the
four method-descriptor call specializations in `frame.rs` do the same.
`bind_for` subtracts the instance from both numbers.
The messages now read as their counterparts do:
- `_PyArg_CheckPositional`: `find expected at least 1 argument, got 0`,
with the singular when the count is one.
- `_PyArg_UnpackKeywords`: `split() got an unexpected keyword argument
'bogus'`, and `cast() missing required argument 'format' (pos 1)` for a
parameter a call may pass by name. A positional-only parameter is only
ever counted, so it keeps the first form.
A binding that happens where the name isn't known leaves it off, the way
`_PyArg_Parser.fname` is NULL.
`test_find_etc_raise_correct_error_messages` now passes in both
`test_bytes` and `string_tests`.
Assisted-by: Claude
* Name the type whose constructor or initializer bound the arguments
`Constructor::slot_new` and `Initializer::slot_init` bound their arguments
without a name, and so did the slots that override them, so a constructor
that was called wrongly said only `expected 1 argument, got 0`.
Both defaults and every override now name the type the slot was written
for, not the subclass being constructed and not the module `tp_name`
carries: `float expected at most 1 argument, got 2`, and `deque expected
at most 2 arguments, got 3` for a `deque` subclass.
`slice()` and `range()` counted their own arguments and raised messages of
their own; they now raise the one `_PyArg_CheckPositional` raises, which
makes `test_range_constructor_error_messages` pass.
Assisted-by: Claude
This commit fix `RangeTest.test_range_iterators_invocation` in
[`test_range.py`](https://github.com/RustPython/RustPython/blob/main/Lib/test/test_range.py#L507).
This is last `TODO` in `test_range.py`.
By add slot tp_new to both types and return new_type_error, prevent
creation of range_iterator and longrange_iterator by calling its type.
Signed-off-by: snowapril <sinjihng@gmail.com>
- add a special_retrieve fudge function to the PyValue trait
- define the special_retrieve function for PyInt
- remove blocks on successful tests to reflect effect of changes