[pypy-commit] pypy default: make it work on 2.5

alex_gaynor noreply at buildbot.pypy.org
Fri Oct 7 17:26:48 CEST 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r47861:a74c03d6d1fb
Date: 2011-10-07 11:26 -0400
http://bitbucket.org/pypy/pypy/changeset/a74c03d6d1fb/

Log:	make it work on 2.5

diff --git a/pypy/jit/codewriter/test/test_jtransform.py b/pypy/jit/codewriter/test/test_jtransform.py
--- a/pypy/jit/codewriter/test/test_jtransform.py
+++ b/pypy/jit/codewriter/test/test_jtransform.py
@@ -1,6 +1,18 @@
 import py
-import itertools
 import random
+try:
+    from itertools import product
+except ImportError:
+    # Python 2.5, this is taken from the CPython docs, but simplified.
+    def product(*args):
+        # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
+        # product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111
+        pools = map(tuple, args)
+        result = [[]]
+        for pool in pools:
+            result = [x+[y] for x in result for y in pool]
+        for prod in result:
+            yield tuple(prod)
 
 from pypy.objspace.flow.model import FunctionGraph, Block, Link
 from pypy.objspace.flow.model import SpaceOperation, Variable, Constant
@@ -256,7 +268,7 @@
             assert op1.result is None
 
 def test_calls():
-    for RESTYPE, with_void, with_i, with_r, with_f in itertools.product(
+    for RESTYPE, with_void, with_i, with_r, with_f in product(
         [lltype.Signed, rclass.OBJECTPTR, lltype.Float, lltype.Void],
         [False, True],
         [False, True],


More information about the pypy-commit mailing list