From 9dec03571f2ec588dfc15ff438c85fe25989dcc1 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Tue, 30 Jun 2015 12:49:04 -0400 Subject: Issue #24528: Improve error message for awaits in comprehensions --- Python/compile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Python/compile.c') diff --git a/Python/compile.c b/Python/compile.c index 1977c3a1bfc..2202e8f3a1c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -3856,7 +3856,10 @@ compiler_visit_expr(struct compiler *c, expr_ty e) if (c->u->u_ste->ste_type != FunctionBlock) return compiler_error(c, "'await' outside function"); - /* this check won't be triggered while we have AWAIT token */ + if (c->u->u_scope_type == COMPILER_SCOPE_COMPREHENSION) + return compiler_error( + c, "'await' expressions in comprehensions are not supported"); + if (c->u->u_scope_type != COMPILER_SCOPE_ASYNC_FUNCTION) return compiler_error(c, "'await' outside async function"); -- cgit v1.2.3