Author: Antonio Cuni <[email protected]>
Branch: py3k
Changeset: r51734:0f9987682c05
Date: 2012-01-24 18:26 +0100
http://bitbucket.org/pypy/pypy/changeset/0f9987682c05/
Log: kill code to support tuple unpacking inside function arguments,
which is no longer supported in python3
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
@@ -1126,14 +1126,6 @@
class AbstractFunctionCodeGenerator(PythonCodeGenerator):
- def _handle_nested_args(self, args):
- for i in range(len(args)):
- arg = args[i]
- if isinstance(arg, ast.Tuple):
- self.update_position(arg.lineno)
- self.name_op(".%d" % (i,), ast.Load)
- arg.walkabout(self)
-
def _get_code_flags(self):
scope = self.scope
assert isinstance(scope, symtable.FunctionScope)
@@ -1171,10 +1163,8 @@
args = func.args
assert isinstance(args, ast.arguments)
if args.args:
- self._handle_nested_args(args.args)
self.argcount = len(args.args)
if args.kwonlyargs:
- self._handle_nested_args(args.kwonlyargs)
self.kwonlyargcount = len(args.kwonlyargs)
if func.body:
for i in range(start, len(func.body)):
@@ -1188,7 +1178,6 @@
args = lam.args
assert isinstance(args, ast.arguments)
if args.args:
- self._handle_nested_args(args.args)
self.argcount = len(args.args)
# Prevent a string from being the first constant and thus a docstring.
self.add_const(self.space.w_None)
diff --git a/pypy/interpreter/astcompiler/symtable.py
b/pypy/interpreter/astcompiler/symtable.py
--- a/pypy/interpreter/astcompiler/symtable.py
+++ b/pypy/interpreter/astcompiler/symtable.py
@@ -508,28 +508,14 @@
if arguments.kwarg:
self.note_symbol(arguments.kwarg, SYM_PARAM)
scope.note_keywords_arg(arguments.kwarg)
- if arguments.args:
- self._handle_nested_params(arguments.args)
def _handle_params(self, params, is_toplevel):
for i in range(len(params)):
arg = params[i]
if isinstance(arg, ast.Name):
self.note_symbol(arg.id, SYM_PARAM)
- elif isinstance(arg, ast.Tuple):
- # Tuple unpacking in the argument list. Add a secret variable
- # name to recieve the tuple with.
- if is_toplevel:
- self.implicit_arg(i)
else:
raise AssertionError("unknown parameter type")
- if not is_toplevel:
- self._handle_nested_params(params)
-
- def _handle_nested_params(self, params):
- for param in params:
- if isinstance(param, ast.Tuple):
- self._handle_params(param.elts, False)
def visit_Name(self, name):
if name.ctx == ast.Load:
diff --git a/pypy/interpreter/astcompiler/test/test_symtable.py
b/pypy/interpreter/astcompiler/test/test_symtable.py
--- a/pypy/interpreter/astcompiler/test/test_symtable.py
+++ b/pypy/interpreter/astcompiler/test/test_symtable.py
@@ -124,12 +124,6 @@
assert scp.has_keywords_arg
assert not scp.has_variable_arg
assert scp.lookup("x") == symtable.SCOPE_LOCAL
- scp = self.func_scope("def f((x, y), a): pass")
- for name in ("x", "y", "a"):
- assert scp.lookup(name) == symtable.SCOPE_LOCAL
- scp = self.func_scope("def f(((a, b), c)): pass")
- for name in ("a", "b", "c"):
- assert scp.lookup(name) == symtable.SCOPE_LOCAL
def test_arguments_kwonly(self):
scp = self.func_scope("def f(a, *, b): pass")
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit