self.assertEqual(ls[:8], list(example[:8]))
self.assertEqual(ls[-8:], list(example[-8:]))
+ def test_gh_128961(self):
+ a = array.array('i')
+ it = iter(a)
+ list(it)
+ it.__setstate__(0)
+ self.assertRaises(StopIteration, next, it)
+
+
if __name__ == "__main__":
unittest.main()
Py_ssize_t index = PyLong_AsSsize_t(state);
if (index == -1 && PyErr_Occurred())
return NULL;
- if (index < 0)
- index = 0;
- else if (index > Py_SIZE(self->ao))
- index = Py_SIZE(self->ao); /* iterator exhausted */
- self->index = index;
+ arrayobject *ao = self->ao;
+ if (ao != NULL) {
+ if (index < 0) {
+ index = 0;
+ }
+ else if (index > Py_SIZE(ao)) {
+ index = Py_SIZE(ao); /* iterator exhausted */
+ }
+ self->index = index;
+ }
Py_RETURN_NONE;
}