[issue26188] Provide more helpful error message when `await` is called inside non-`async` method

2017-12-20 Thread Andrew Svetlov

Andrew Svetlov  added the comment:

Nothing to do.
Python parser always report with such text on syntax error, there is nothing 
special for async/await

--
nosy: +asvetlov
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26188] Provide more helpful error message when `await` is called inside non-`async` method

2016-02-02 Thread Martin Panter

Martin Panter added the comment:

I’m not that familiar with the parser either. Maybe I remember a flag or 
something saying “we are inside an async def function”, which changes “await” 
from a user identifier into a reserved keyword. But I can’t imagine how that 
flag will help much with this proposal. The problem I think is “await” is never 
treated as a reserved keyword when the flag is not set.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26188] Provide more helpful error message when `await` is called inside non-`async` method

2016-02-02 Thread Nicholas Chammas

Nicholas Chammas added the comment:

Related discussions about providing more helpful syntax error messages:

* http://bugs.python.org/issue1634034
* http://bugs.python.org/issue400734
* http://bugs.python.org/issue20608

>From the discussion on issue1634034, it looks like providing better messages 
>in the general case of a syntax error is quite difficult. But perhaps in 
>limited cases like this one we can do better.

Parsers are a bit over my head. Martin, is it difficult to distinguish between 
`await` as a regular name and `await` as a special token?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26188] Provide more helpful error message when `await` is called inside non-`async` method

2016-01-26 Thread Martin Panter

Martin Panter added the comment:

According to PEP 492, “await” is still allowed to be an ordinary identifier in 
non-async functions until Python 3.7. Which means you are still allowed to write

def oh_hai():
await = "something"

The proposed error message would need to be smart enough to distinguish the two 
cases.

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26188] Provide more helpful error message when `await` is called inside non-`async` method

2016-01-24 Thread SilentGhost

Changes by SilentGhost :


--
components: +asyncio
nosy: +giampaolo.rodola, gvanrossum, haypo, pitrou, yselivanov

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26188] Provide more helpful error message when `await` is called inside non-`async` method

2016-01-24 Thread aditya gupta

Changes by aditya gupta :


--
nosy: +aditya gupta

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26188] Provide more helpful error message when `await` is called inside non-`async` method

2016-01-23 Thread Nicholas Chammas

New submission from Nicholas Chammas:

Here is the user interaction:

```python
$ python3
Python 3.5.1 (default, Dec  7 2015, 21:59:10) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def oh_hai():
... await something()
  File "", line 2
await something()
  ^
SyntaxError: invalid syntax
```

It would be helpful if Python could tell the user something more specific about 
_why_ the syntax is invalid. Is that possible?

For example, in the case above, an error message along the following lines 
would be much more helpful:

```
SyntaxError: Cannot call `await` inside non-`async` method.
```

Without a hint like this, it's too easy to miss the obvious and waste time 
eye-balling the code, like I did. :-)

--
components: Interpreter Core
messages: 258879
nosy: Nicholas Chammas
priority: normal
severity: normal
status: open
title: Provide more helpful error message when `await` is called inside 
non-`async` method
versions: Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com