xrange
xrange copied to clipboard
Slicing logic
There's a bit of a bug in the slicing logic - specifically, the step passed through the slice refers to something different from the _step in the xrange. See the commit message and patch for the solution.
Thanks for finding the bug -- I didn't know that about slice steps (and apparently hadn't thought to try). Unfortunately it looks like there are some bugs remaining -- try adding this to test_xrange.py:
def test_getitem_slice_step(self):
r = xrange(0, 10, 2)
self.assertEqual(r[:], xrange(0, 10, 2))
self.assertEqual(r[0:5], xrange(0, 10, 2))
self.assertEqual(r[0:5:1], xrange(0, 10, 2))
self.assertEqual(r[0:5:2], xrange(0, 10, 4))
If you want to take a crack at updating the pull request, please do; if not, I will see if I can fix these issues when time permits.