[pypy-svn] r57571 - pypy/dist/pypy/module/itertools

arigo at codespeak.net arigo at codespeak.net
Fri Aug 22 10:28:49 CEST 2008


Author: arigo
Date: Fri Aug 22 10:28:47 2008
New Revision: 57571

Modified:
   pypy/dist/pypy/module/itertools/interp_itertools.py
Log:
Sorry, I did not run all the tests.


Modified: pypy/dist/pypy/module/itertools/interp_itertools.py
==============================================================================
--- pypy/dist/pypy/module/itertools/interp_itertools.py	(original)
+++ pypy/dist/pypy/module/itertools/interp_itertools.py	Fri Aug 22 10:28:47 2008
@@ -443,10 +443,6 @@
         self.identity_fun = (self.space.is_w(w_fun, space.w_None))
         self.w_fun = w_fun
 
-        if len(args_w) == 0:
-            raise OperationError(space.w_TypeError,
-                      space.wrap("imap() must have at least two arguments"))
-
         iterators_w = []
         i = 0
         for iterable_w in args_w:
@@ -476,6 +472,9 @@
 
 
 def W_IMap___new__(space, w_subtype, w_fun, args_w):
+    if len(args_w) == 0:
+        raise OperationError(space.w_TypeError,
+                  space.wrap("imap() must have at least two arguments"))
     return space.wrap(W_IMap(space, w_fun, args_w))
 
 W_IMap.typedef = TypeDef(
@@ -510,6 +509,14 @@
 class W_IZip(W_IMap):
     _error_name = "izip"
 
+    def next_w(self):
+        # argh.  izip(*args) is almost like imap(None, *args) except
+        # that the former needs a special case for len(args)==0
+        # while the latter just raises a TypeError in this situation.
+        if len(self.iterators_w) == 0:
+            raise OperationError(self.space.w_StopIteration, self.space.w_None)
+        return W_IMap.next_w(self)
+
 def W_IZip___new__(space, w_subtype, args_w):
     return space.wrap(W_IZip(space, space.w_None, args_w))
 



More information about the Pypy-commit mailing list