[pypy-commit] pypy py3.5: Set oparg to valid value in case of dict unpack (max -> min), skip walkabout if keyword.arg is None in AST

raffael_t pypy.commits at gmail.com
Mon Jun 27 12:34:08 EDT 2016


Author: Raffael Tfirst <raffael.tfirst at gmail.com>
Branch: py3.5
Changeset: r85409:7767a5f257ee
Date: 2016-06-27 18:33 +0200
http://bitbucket.org/pypy/pypy/changeset/7767a5f257ee/

Log:	Set oparg to valid value in case of dict unpack (max -> min), skip
	walkabout if keyword.arg is None in AST

diff --git a/pypy/interpreter/astcompiler/ast.py b/pypy/interpreter/astcompiler/ast.py
--- a/pypy/interpreter/astcompiler/ast.py
+++ b/pypy/interpreter/astcompiler/ast.py
@@ -3569,7 +3569,8 @@
     def visit_sequence(self, seq):
         if seq is not None:
             for node in seq:
-                node.walkabout(self)
+                if node is not None:
+                    node.walkabout(self)
 
     def visit_kwonlydefaults(self, seq):
         if seq is not None:
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
@@ -1115,7 +1115,7 @@
         # a new dict. If there is one dict and it's an unpacking, then
         #it needs to be copied into a new dict.
         while containers > 1 or is_unpacking:
-            oparg = max(containers, 255)
+            oparg = min(containers, 255)
             self.emit_op_arg(ops.BUILD_MAP_UNPACK, oparg)
             containers -= (oparg - 1)
             is_unpacking = 0
diff --git a/pypy/interpreter/astcompiler/tools/asdl_py.py b/pypy/interpreter/astcompiler/tools/asdl_py.py
--- a/pypy/interpreter/astcompiler/tools/asdl_py.py
+++ b/pypy/interpreter/astcompiler/tools/asdl_py.py
@@ -279,7 +279,8 @@
         self.emit("def visit_sequence(self, seq):", 1)
         self.emit("if seq is not None:", 2)
         self.emit("for node in seq:", 3)
-        self.emit("node.walkabout(self)", 4)
+        self.emit("if node is not None:", 4)
+        self.emit("node.walkabout(self)", 5)
         self.emit("")
         self.emit("def visit_kwonlydefaults(self, seq):", 1)
         self.emit("if seq is not None:", 2)
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1369,16 +1369,8 @@
         self.pushvalue(w_sum)
         
     def BUILD_MAP_UNPACK(self, itemcount, next_instr):
-        self.BUILD_MAP(itemcount, next_instr)
-        #w_sum = self.space.newdict()
-        #for i in range(itemcount, 0, -1):
-        #    w_item = self.popvalue()
-        #    #self.space.peek(i)
-        #    self.space.call_method(w_sum, 'update', w_item)
-        ##while itemcount != 0:
-        ##    self.popvalue()
-        ##    itemcount -= 1
-        #self.pushvalue(w_sum)
+        w_sum = self.unpack_helper(itemcount, next_instr)
+        self.pushvalue(self.space.newdict(w_sum))
 ### ____________________________________________________________ ###
 
 class ExitFrame(Exception):


More information about the pypy-commit mailing list