Author: Chirag Jadwani <[email protected]>
Branch: 
Changeset: r58440:8d78e41a3511
Date: 2012-08-01 02:09 +0530
http://bitbucket.org/pypy/pypy/changeset/8d78e41a3511/

Log:    Minor fix in lib_pypy.itertools.count, added test

diff --git a/lib_pypy/itertools.py b/lib_pypy/itertools.py
--- a/lib_pypy/itertools.py
+++ b/lib_pypy/itertools.py
@@ -215,15 +215,18 @@
         self._counter += self._step
         return c
 
+    def _single_argument(self):
+        return self._step == 1 and isinstance(self._step, int)
+
     def __reduce__(self):
-        if self._step == 1:
+        if self._single_argument():
             args = (self._counter,)
         else:
             args = (self._counter, self._step)
         return (self.__class__, args)
 
     def __repr__(self):
-        if self._step == 1:
+        if self._single_argument():
             return 'count(%r)' % (self._counter)
         return 'count(%r, %r)' % (self._counter, self._step)
 
diff --git a/lib_pypy/pypy_test/test_itertools.py 
b/lib_pypy/pypy_test/test_itertools.py
--- a/lib_pypy/pypy_test/test_itertools.py
+++ b/lib_pypy/pypy_test/test_itertools.py
@@ -65,3 +65,7 @@
         next(tw)
         raises(StopIteration, next, tw)
         raises(StopIteration, next, tw)
+
+    def test_count_repr(self):
+        c = itertools.count(10, 1.0)
+        assert repr(c) == 'count(10, 1.0)'
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to