##// END OF EJS Templates
Fix improper non-SyntaxError in return outside of function....
Matthias Bussonnier -
Show More
@@ -112,6 +112,7 b' class _AsyncSyntaxErrorVisitor(ast.NodeVisitor):'
112 if isinstance(node, func_types) and should_traverse:
112 if isinstance(node, func_types) and should_traverse:
113 self.depth += 1
113 self.depth += 1
114 super().generic_visit(node)
114 super().generic_visit(node)
115 self.depth -= 1
115 elif isinstance(node, invalid_types_by_depth[self.depth]):
116 elif isinstance(node, invalid_types_by_depth[self.depth]):
116 raise SyntaxError()
117 raise SyntaxError()
117 else:
118 else:
@@ -139,7 +139,13 b' if sys.version_info > (3, 5):'
139 tl_err_test_cases = self._get_top_level_cases()
139 tl_err_test_cases = self._get_top_level_cases()
140 tl_err_test_cases.extend(self._get_ry_syntax_errors())
140 tl_err_test_cases.extend(self._get_ry_syntax_errors())
141
141
142 vals = ('return', 'yield', 'yield from (_ for _ in range(3))')
142 vals = ('return', 'yield', 'yield from (_ for _ in range(3))',
143 dedent('''
144 def f():
145 pass
146 return
147 '''),
148 )
143
149
144 for test_name, test_case in tl_err_test_cases:
150 for test_name, test_case in tl_err_test_cases:
145 # This example should work if 'pass' is used as the value
151 # This example should work if 'pass' is used as the value
General Comments 0
You need to be logged in to leave comments. Login now