Author: Carl Friedrich Bolz-Tereick <cfb...@gmx.de> Branch: py3.5 Changeset: r94913:179c172169f1 Date: 2018-07-28 14:06 +0200 http://bitbucket.org/pypy/pypy/changeset/179c172169f1/
Log: fix annotation bug reported by hubo on pypy-dev 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 @@ -622,6 +622,10 @@ assert isinstance(args, ast.arguments) if args.args: self._visit_arg_annotations(args.args) + if args.vararg: + self._visit_arg_annotation(args.vararg) + if args.kwarg: + self._visit_arg_annotation(args.kwarg) if args.kwonlyargs: self._visit_arg_annotations(args.kwonlyargs) if func.returns: @@ -630,8 +634,11 @@ def _visit_arg_annotations(self, args): for arg in args: assert isinstance(arg, ast.arg) - if arg.annotation: - arg.annotation.walkabout(self) + self._visit_arg_annotation(arg) + + def _visit_arg_annotation(self, arg): + if arg.annotation: + arg.annotation.walkabout(self) def visit_Name(self, name): if name.ctx == ast.Load: diff --git a/pypy/interpreter/test/test_syntax.py b/pypy/interpreter/test/test_syntax.py --- a/pypy/interpreter/test/test_syntax.py +++ b/pypy/interpreter/test/test_syntax.py @@ -691,6 +691,16 @@ "bye" : 5, "kw" : 6, "return" : 42} """ + def test_bug_annotations_lambda(self): + """ + # those used to crash + def broken(*a: lambda x: None): + pass + + def broken(**a: lambda x: None): + pass + """ + class AppTestSyntaxError: def test_tokenizer_error_location(self): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit