Commit Graph
14 Commits
Author SHA1 Message Date
Jeong, YunWon 516a116f9a Name the function a failed argument binding was binding for (#8630)
* 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
2026-09-01 06:57:58 +09:00
Shahar Naveh 4673fb8b4a Update test_range.py from 3.14.4 (#7605) 2026-04-15 14:15:27 +09:00
Daeun Lee 97d8529c74 Fix range attributes type 2022-07-27 14:43:47 +09:00
siontama 9e3079c565 Fix: range beyond the isize range
* Check if start + step is greater than sys.maxsize
2022-07-23 16:59:14 +09:00
Jeong Yunwon 3d27f163e4 adjust failing markers for test_{builtin,decimal,float,range} 2022-07-18 04:38:26 +09:00
CPython developers 33690be35b Update tests from CPython 3.10.5 2022-07-18 04:07:35 +09:00
snowapril d0afc4c3bc set range iter type not creatable by calling type
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>
2021-08-26 16:15:28 +09:00
jfh f3a074ba90 Adds reduce, length_hint and set_state to range iterators. 2021-08-05 23:56:01 +03:00
jfh 1115511e3d Add fast range iterator. 2021-07-30 19:19:30 +03:00
jfh c1f1f1ef02 Fix a number of range issues. 2021-06-15 19:20:54 +03:00
jfh 7be043fa5a Fix small miscalculation when reversing a range. 2021-06-14 22:31:50 +03:00
Robert Booth af6b230dad Change int type checking, amend tests
- 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
2021-04-25 01:18:57 +09:00
Robert Booth 55f2fa0a73 add test_range 2021-04-23 10:17:32 +09:00
Robert Booth fa20c260d7 test_range from cpython [v3.8.7|✔] 2021-04-23 10:02:36 +09:00