[pypy-commit] pypy py3.5: fixes stack computation error, adds a test. removed old argument calculation dating back to 444ebc97d,

plan_rich pypy.commits at gmail.com
Mon Jun 20 05:18:46 EDT 2016


Author: Richard Plangger <planrichi at gmail.com>
Branch: py3.5
Changeset: r85234:3dd13008b96b
Date: 2016-06-20 11:17 +0200
http://bitbucket.org/pypy/pypy/changeset/3dd13008b96b/

Log:	fixes stack computation error, adds a test. removed old argument
	calculation dating back to 444ebc97d, the new behaviour is
	implemented, but the old calculation argument was provided to the
	byte code

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
@@ -1133,11 +1133,6 @@
 
     def _make_call(self, n, # args already pushed
                    args, keywords):
-        #, starargs, kwargs
-        if args is not None:
-            arg = len(args) + n
-        else:
-            arg = n
         call_type = 0
         # the number of tuples and dictionaries on the stack
         nsubargs = 0
@@ -1207,11 +1202,11 @@
                     # Pack it all up
                     function_pos = n + (code & 1) + nkw + 1
                     self.emit_op_arg(ops.BUILD_MAP_UNPACK_WITH_CALL, (nsubkwargs | (function_pos << 8)))
-        
+
         assert n < 1<<8
         assert nkw < 1<<24
         n |= nkw << 8;
-        
+
         op = 0
         if call_type == 0:
             op = ops.CALL_FUNCTION
@@ -1221,7 +1216,7 @@
             op = ops.CALL_FUNCTION_KW
         elif call_type == 3:
             op = ops.CALL_FUNCTION_VAR_KW
-        self.emit_op_arg(op, arg)
+        self.emit_op_arg(op, n)
 
     def visit_Call(self, call):
         self.update_position(call.lineno)
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
@@ -1306,3 +1306,9 @@
             counts = self.count_instructions(source)
             assert ops.BUILD_SET not in counts
             assert ops.LOAD_CONST in counts
+
+    def test_call_function_var(self):
+        source = """call(*me)"""
+        code, blocks = generate_function_code(source, self.space)
+        # there is a stack computation error
+        assert blocks[0].instructions[3].arg == 0


More information about the pypy-commit mailing list