* 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 directory contains all of the Python files that make up the standard
library for RustPython.
Most of these files are copied over from the CPython repository (the 3.7
branch), with slight modifications to allow them to work under RustPython. The
current goal is to complete the standard library with as few modifications as
possible. Current modifications are just temporary workarounds for bugs/missing
feature within the RustPython implementation.
The first big module we are targeting is unittest, so we can leverage the
CPython test suite.