[pypy-commit] pypy default: Python 2.6 compat

arigo noreply at buildbot.pypy.org
Sun Oct 21 19:30:13 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r58328:cc4bf90cc36f
Date: 2012-10-21 19:29 +0200
http://bitbucket.org/pypy/pypy/changeset/cc4bf90cc36f/

Log:	Python 2.6 compat

diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -761,6 +761,20 @@
         next_instr += jumpby
         return next_instr
 
+    def JUMP_IF_FALSE(self, stepby, next_instr):
+        # Python <= 2.6 only
+        w_cond = self.peekvalue()
+        if not self.space.is_true(w_cond):
+            next_instr += stepby
+        return next_instr
+
+    def JUMP_IF_TRUE(self, stepby, next_instr):
+        # Python <= 2.6 only
+        w_cond = self.peekvalue()
+        if self.space.is_true(w_cond):
+            next_instr += stepby
+        return next_instr
+
     def POP_JUMP_IF_FALSE(self, target, next_instr):
         w_value = self.popvalue()
         if not self.space.is_true(w_value):
@@ -1068,7 +1082,10 @@
 
     def LIST_APPEND(self, oparg, next_instr):
         w = self.popvalue()
-        v = self.peekvalue(oparg - 1)
+        if sys.version_info < (2, 7):
+            v = self.popvalue()
+        else:
+            v = self.peekvalue(oparg - 1)
         self.space.call_method(v, 'append', w)
 
     def DELETE_FAST(self, varindex, next_instr):
diff --git a/pypy/objspace/flow/test/test_objspace.py b/pypy/objspace/flow/test/test_objspace.py
--- a/pypy/objspace/flow/test/test_objspace.py
+++ b/pypy/objspace/flow/test/test_objspace.py
@@ -1136,6 +1136,14 @@
                                               'inplace_add': 1,
                                               'setitem': 1}
 
+    def test_list_append(self):
+        def f(iterable):
+            return [5 for x in iterable]
+        graph = self.codetest(f)
+        assert self.all_operations(graph) == {'getattr': 1,
+                                              'iter': 1, 'newlist': 1,
+                                              'next': 1, 'simple_call': 1}
+
 DATA = {'x': 5,
         'y': 6}
 


More information about the pypy-commit mailing list