[pypy-svn] pypy default: Fix repr(itertools.count(x, 1.0))

alex_gaynor commits-noreply at bitbucket.org
Mon Jan 24 20:49:30 CET 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r41268:52c5ecc53671
Date: 2011-01-24 14:49 -0500
http://bitbucket.org/pypy/pypy/changeset/52c5ecc53671/

Log:	Fix repr(itertools.count(x, 1.0))

diff --git a/pypy/module/itertools/test/test_itertools.py b/pypy/module/itertools/test/test_itertools.py
--- a/pypy/module/itertools/test/test_itertools.py
+++ b/pypy/module/itertools/test/test_itertools.py
@@ -1,6 +1,7 @@
 import py
 from pypy.conftest import gettestobjspace
 
+
 class AppTestItertools: 
     def setup_class(cls):
         cls.space = gettestobjspace(usemodules=['itertools'])
@@ -26,6 +27,8 @@
         assert repr(it) == 'count(123)'
         it.next()
         assert repr(it) == 'count(124)'
+        it = itertools.count(12.1, 1.0)
+        assert repr(it) == 'count(12.1, 1.0)'
 
     def test_repeat(self):
         import itertools

diff --git a/pypy/module/itertools/interp_itertools.py b/pypy/module/itertools/interp_itertools.py
--- a/pypy/module/itertools/interp_itertools.py
+++ b/pypy/module/itertools/interp_itertools.py
@@ -23,7 +23,8 @@
     def repr_w(self):
         space = self.space
         c = space.str_w(space.repr(self.w_c))
-        if space.eq_w(self.w_step, space.wrap(1)):
+        if (space.isinstance_w(self.w_step, space.w_int) and
+            space.eq_w(self.w_step, space.wrap(1))):
             s = 'count(%s)' % (c,)
         else:
             step = space.str_w(space.repr(self.w_step))


More information about the Pypy-commit mailing list