[New-bugs-announce] [issue30029] Compiler "'await' outside function" error message is unreachable
anthony shaw
report at bugs.python.org
Sun Apr 9 19:26:16 EDT 2017
New submission from anthony shaw:
This is related to issue26188,
Using await in a simple statement (outside of an async def method) raises SyntaxError with the unhelpful message "invalid syntax".
It seems obvious once you've read PEP492 in detail, but I think that as more and more developers use async/await this will stump lots of people.
I've been trying to pick apart where this constraint is raised to see whether I can help with a PR, I've been through Grammar, Parser and then the AST and Compiler.
Looking at https://github.com/python/cpython/blob/master/Python/compile.c#L4307-L4319 I can see there are helpful error messages, but during the tokenizer phase it checks that the syntax cannot be used unless you're within an async def method
https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Parser/tokenizer.c#L1574-L1583
I can't reproduce this in a REPL for 3.7.0a0, it never gets any further than the grammar or tokenizer phase.
----------
messages: 291398
nosy: anthonypjshaw
priority: normal
severity: normal
status: open
title: Compiler "'await' outside function" error message is unreachable
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30029>
_______________________________________
More information about the New-bugs-announce
mailing list