New submission from yegle <cnye...@gmail.com>: This also affects xrange in Python2, so I chose the affected version as python27.
range object (and xrange in Python2) has __len__(), but the range_iterator object created from __reversed__() doesn't have __len__. Python2: >>> x = xrange(10) >>> len(x) 10 >>> reversed(x) <rangeiterator object at 0x7f86065684e0> >>> y = reversed(x) >>> len(y) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: object of type 'rangeiterator' has no len() Python3.6 >>> x = range(10) >>> len(x) 10 >>> len(reversed(x)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: object of type 'range_iterator' has no len() ---------- components: Interpreter Core messages: 306458 nosy: yegle priority: normal severity: normal status: open title: range_iterator doesn't have length, leads to surprised result versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32065> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com