Kaydet (Commit) 25ea45db authored tarafından Kristján Valur Jónsson's avatar Kristján Valur Jónsson

Merge with 3.3

...@@ -380,6 +380,18 @@ class RangeTest(unittest.TestCase): ...@@ -380,6 +380,18 @@ class RangeTest(unittest.TestCase):
it = pickle.loads(d) it = pickle.loads(d)
self.assertEqual(list(it), data[1:]) self.assertEqual(list(it), data[1:])
def test_exhausted_iterator_pickling(self):
r = range(20)
i = iter(r)
while True:
r = next(i)
if r == 19:
break
d = pickle.dumps(i)
i2 = pickle.loads(d)
self.assertEqual(list(i), [])
self.assertEqual(list(i2), [])
def test_odd_bug(self): def test_odd_bug(self):
# This used to raise a "SystemError: NULL result without error" # This used to raise a "SystemError: NULL result without error"
# because the range validation step was eating the exception # because the range validation step was eating the exception
......
...@@ -807,7 +807,7 @@ rangeiter_setstate(rangeiterobject *r, PyObject *state) ...@@ -807,7 +807,7 @@ rangeiter_setstate(rangeiterobject *r, PyObject *state)
long index = PyLong_AsLong(state); long index = PyLong_AsLong(state);
if (index == -1 && PyErr_Occurred()) if (index == -1 && PyErr_Occurred())
return NULL; return NULL;
if (index < 0 || index >= r->len) { if (index < 0 || index > r->len) {
PyErr_SetString(PyExc_ValueError, "index out of range"); PyErr_SetString(PyExc_ValueError, "index out of range");
return NULL; return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment