[pypy-commit] pypy py3.5: Use 3.5 order of evaluation for dict literals

rlamy pypy.commits at gmail.com
Wed Nov 2 21:00:13 EDT 2016


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r88092:f205cd1fb012
Date: 2016-11-03 00:59 +0000
http://bitbucket.org/pypy/pypy/changeset/f205cd1fb012/

Log:	Use 3.5 order of evaluation for dict literals

diff --git a/pypy/interpreter/astcompiler/assemble.py b/pypy/interpreter/astcompiler/assemble.py
--- a/pypy/interpreter/astcompiler/assemble.py
+++ b/pypy/interpreter/astcompiler/assemble.py
@@ -662,7 +662,7 @@
     ops.LOAD_DEREF: 1,
     ops.STORE_DEREF: -1,
     ops.DELETE_DEREF: 0,
-    
+
     ops.GET_AWAITABLE: 0,
     ops.SETUP_ASYNC_WITH: 0,
     ops.BEFORE_ASYNC_WITH: 1,
@@ -682,10 +682,10 @@
     ops.JUMP_IF_FALSE_OR_POP: 0,
     ops.POP_JUMP_IF_TRUE: -1,
     ops.POP_JUMP_IF_FALSE: -1,
-    # TODO 
+    # TODO
     ops.JUMP_IF_NOT_DEBUG: 0,
 
-    # TODO 
+    # TODO
     ops.BUILD_LIST_FROM_ARG: 1,
     # TODO
     ops.LOAD_CLASSDEREF: 1,
diff --git a/pypy/interpreter/astcompiler/codegen.py b/pypy/interpreter/astcompiler/codegen.py
--- a/pypy/interpreter/astcompiler/codegen.py
+++ b/pypy/interpreter/astcompiler/codegen.py
@@ -1216,8 +1216,8 @@
                     # in some cases, so another error has to be fixed in order for
                     # this to work, otherwise it breaks everything
                     # after fix: remove dirty fixes in pyopcode
+                    key.walkabout(self)
                     d.values[i].walkabout(self)
-                    key.walkabout(self)
                     elements += 1
         if elements or containers == 0:
             self.emit_op_arg(ops.BUILD_MAP, elements)
@@ -1301,8 +1301,8 @@
                     nsubkwargs += 1
                 elif nsubkwargs:
                     # A keyword argument and we already have a dict.
+                    self.load_const(self.space.wrap(kw.arg.decode('utf-8')))
                     kw.value.walkabout(self)
-                    self.load_const(self.space.wrap(kw.arg.decode('utf-8')))
                     nseen += 1
                 else:
                     # keyword argument
diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py
--- a/pypy/interpreter/astcompiler/test/test_compiler.py
+++ b/pypy/interpreter/astcompiler/test/test_compiler.py
@@ -792,7 +792,7 @@
             for i in arg:
                 ret.append(i)
             return ret
-        
+
         args = [4,5,6]
         res = call(*args, *args)
         """)
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -38,7 +38,7 @@
 # time you make pyc files incompatible.  This value ends up in the frozen
 # importlib, via MAGIC_NUMBER in module/_frozen_importlib/__init__.
 
-pypy_incremental_magic = 96 # bump it by 16
+pypy_incremental_magic = 112 # bump it by 16
 assert pypy_incremental_magic % 16 == 0
 assert pypy_incremental_magic < 3000 # the magic number of Python 3. There are
                                      # no known magic numbers below this value
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1327,8 +1327,8 @@
     def BUILD_MAP(self, itemcount, next_instr):
         w_dict = self.space.newdict()
         for i in range(itemcount-1, -1, -1):
-            w_key = self.peekvalue(2 * i)
-            w_value = self.peekvalue(2 * i + 1)
+            w_value = self.peekvalue(2 * i)
+            w_key = self.peekvalue(2 * i + 1)
             self.space.setitem(w_dict, w_key, w_value)
         self.popvalues(2 * itemcount)
         self.pushvalue(w_dict)


More information about the pypy-commit mailing list