This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Make not yielding from or awaiting a coroutine a SyntaxError
Type: enhancement Stage: resolved
Components: Windows Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Decorater, paul.moore, r.david.murray, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2016-07-16 05:16 by Decorater, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (6)
msg270538 - (view) Author: Decorater (Decorater) * Date: 2016-07-16 05:16
Currently there is a waring printed in python when you try to call a coroutine without yieling from or awaiting it but I would like it to be a SyntaxError when this happens instead.
msg270539 - (view) Author: Decorater (Decorater) * Date: 2016-07-16 05:21
I am thinking like this example:

import asyncio

@asyncio.coroutine
def SomeCoroutine():
    print("test...")

@asyncio.coroutine
def SomeNormalFunction():
    SomeCoroutine()

Will print a warning instead I would like it to be a SyntaxError when the function is called that tries to call a coroutine that has not been yielded/awaited at all.
msg270540 - (view) Author: Decorater (Decorater) * Date: 2016-07-16 06:12
Oh it does not happen if you use the asyncio.coroutine decorater but it does do RuntimeWarning if you use the async def on it.
msg270541 - (view) Author: Decorater (Decorater) * Date: 2016-07-16 06:12
So to make it Error it must be :

import asyncio

async def SomeCoroutine():
    print("test...")

SomeCoroutine()
msg270557 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-07-16 12:45
It can't be a syntax error.  There are legitimate reasons for calling a coroutine and then passing around the resulting object before awaiting it.
msg270558 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-07-16 12:48
Also, fyi it was couterproductive to code this as a Windows issue...that alerted the windows experts, but it is not a windows-specific issue, so it just pinged them needlessly.  Also FYI, enahancements can only go into the next feature release, so the correct versions selection would have been 3.6 only.
History
Date User Action Args
2022-04-11 14:58:33adminsetgithub: 71714
2016-07-16 12:48:08r.david.murraysetmessages: + msg270558
2016-07-16 12:45:34r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg270557

resolution: rejected
stage: resolved
2016-07-16 06:12:48Decoratersetmessages: + msg270541
2016-07-16 06:12:08Decoratersetmessages: + msg270540
versions: - Python 3.4
2016-07-16 05:28:11Decoratersettype: enhancement
2016-07-16 05:21:19Decoratersetmessages: + msg270539
2016-07-16 05:16:03Decoratercreate