Skip to content

Conversation

@asazernik
Copy link

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.

… (For example, if the slice step is 1 and the original xrange has _step=2, the resulting xrange should have _step=2, not 1.)
@dcrosta
Copy link
Owner

dcrosta commented Jun 19, 2012

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants