xrange icon indicating copy to clipboard operation
xrange copied to clipboard

Slicing logic

Open asazernik opened this issue 13 years ago • 1 comments

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.

asazernik avatar Jun 19 '12 11:06 asazernik

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.

dcrosta avatar Jun 19 '12 12:06 dcrosta