Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r58967:4e277b9928b6
Date: 2012-11-16 22:50 +0100
http://bitbucket.org/pypy/pypy/changeset/4e277b9928b6/

Log:    Fix lib-python.2.7.test.test_builtin. See comments.

diff --git a/pypy/module/__builtin__/app_functional.py 
b/pypy/module/__builtin__/app_functional.py
--- a/pypy/module/__builtin__/app_functional.py
+++ b/pypy/module/__builtin__/app_functional.py
@@ -207,18 +207,16 @@
         return []
 
     # Gather the iterators and guess the result length (the min of the
-    # input lengths)
+    # input lengths).  If any of the iterators doesn't know its length,
+    # we use 0 (instead of ignoring it and using the other iterators;
+    # see lib-python's test_builtin.test_zip).
     iterators = []
-    min_hint = -1
+    hint = 100000000   # max 100M
     for seq in sequences:
         iterators.append(iter(seq))
-        hint = operator._length_hint(seq, min_hint)
-        if min_hint == -1 or hint < min_hint:
-            min_hint = hint
-    if min_hint == -1:
-        min_hint = 0
+        hint = min(hint, operator._length_hint(seq, 0))
 
-    with _ManagedNewlistHint(min_hint) as result:
+    with _ManagedNewlistHint(hint) as result:
         while True:
             try:
                 items = [next(it) for it in iterators]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to