New submission from Oren Milman: ------------ 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. ---------- components: Interpreter Core files: CPythonTestOutput.txt messages: 278187 nosy: Oren Milman priority: normal severity: normal status: open title: assertion failure in rangeobject.c type: crash versions: Python 3.7 Added file: http://bugs.python.org/file44984/CPythonTestOutput.txt _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28376> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com