Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r58434:64035d1ba94d
Date: 2012-10-26 12:05 +0200
http://bitbucket.org/pypy/pypy/changeset/64035d1ba94d/

Log:    Fix check_number(), as per comments on pull request #80.

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
@@ -43,9 +43,8 @@
                                space.newtuple(args_w)])
 
 def check_number(space, w_obj):
-    if (space.lookup(w_obj, '__add__') is None or
-        space.is_true(space.isinstance(w_obj, space.w_str)) or
-        space.is_true(space.isinstance(w_obj, space.w_unicode))):
+    if (space.lookup(w_obj, '__int__') is None and
+        space.lookup(w_obj, '__float__') is None):
         raise OperationError(space.w_TypeError,
                              space.wrap("expected a number"))
 
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
@@ -35,6 +35,7 @@
 
         raises(TypeError, itertools.count, None)
         raises(TypeError, itertools.count, 'a')
+        raises(TypeError, itertools.count, [])
 
     def test_repeat(self):
         import itertools
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to