[Python-checkins] cpython (merge 3.3 -> default): Merge with 3.3

kristjan.jonsson python-checkins at python.org
Wed Mar 5 00:26:46 CET 2014


http://hg.python.org/cpython/rev/23d9daed4b14
changeset:   89476:23d9daed4b14
parent:      89474:f4a2d0e4e0be
parent:      89475:24d4e52f4f87
user:        Kristján Valur Jónsson <kristjan at ccpgames.com>
date:        Tue Mar 04 23:22:15 2014 +0000
summary:
  Merge with 3.3

files:
  Lib/test/test_range.py |  12 ++++++++++++
  Objects/rangeobject.c  |   2 +-
  2 files changed, 13 insertions(+), 1 deletions(-)


diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py
--- a/Lib/test/test_range.py
+++ b/Lib/test/test_range.py
@@ -380,6 +380,18 @@
                 it = pickle.loads(d)
                 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):
         # This used to raise a "SystemError: NULL result without error"
         # because the range validation step was eating the exception
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -807,7 +807,7 @@
     long index = PyLong_AsLong(state);
     if (index == -1 && PyErr_Occurred())
         return NULL;
-    if (index < 0 || index >= r->len) {
+    if (index < 0 || index > r->len) {
         PyErr_SetString(PyExc_ValueError, "index out of range");
         return NULL;
     }

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list