Message278187
------------ current state ------------
An assertion in Objects/rangeobject.c might fail:
>>> type(iter(range(0)))
<class 'range_iterator'>
>>> type(iter(range(0)))(1, 1, 0)
Assertion failed: step != 0, file ..\Objects\rangeobject.c, line 895
This is caused by the lack of a check whether 'step' is zero, during the creation of a range_iterator object, in rangeiter_new.
Note that during the creation of a range object, the function range_new does check that, by calling validate_step, which leads to the following behavior:
>>> range(1, 1, 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: range() arg 3 must not be zero
>>>
------------ proposed changes ------------
1. In Objects/rangeobject.c in rangeiter_new:
- in case 'step' is zero, raise a ValueError
- in error messages, replace 'rangeiter' with 'range_iterator', as the latter is the name of the type in Python code
2. In Lib/test/test_range.py, add tests for calling the range_iterator type (i.e. creating a range_iterator object)
------------ diff ------------
The proposed patches diff file is attached.
------------ tests ------------
I ran 'python_d.exe -m test -j3' (on my 64-bit Windows 10) with and without the patches, and got quite the same output. (That also means my new tests in test_range passed.)
The outputs of both runs are attached. |
|
Date |
User |
Action |
Args |
2016-10-06 12:00:29 | Oren Milman | set | recipients:
+ Oren Milman |
2016-10-06 12:00:27 | Oren Milman | set | messageid: <1475755227.93.0.551363347905.issue28376@psf.upfronthosting.co.za> |
2016-10-06 12:00:27 | Oren Milman | link | issue28376 messages |
2016-10-06 12:00:27 | Oren Milman | create | |
|