mirror of
https://github.com/python/cpython.git
synced 2025-09-13 12:17:24 +00:00
Issue #26182: Raise DeprecationWarning for improper use of async/await keywords
This commit is contained in:
parent
6775231597
commit
8987c9d219
6 changed files with 125 additions and 56 deletions
|
@ -519,7 +519,7 @@ def sleep(delay, result=None, *, loop=None):
|
|||
h.cancel()
|
||||
|
||||
|
||||
def async(coro_or_future, *, loop=None):
|
||||
def async_(coro_or_future, *, loop=None):
|
||||
"""Wrap a coroutine in a future.
|
||||
|
||||
If the argument is a Future, it is returned directly.
|
||||
|
@ -532,6 +532,11 @@ def async(coro_or_future, *, loop=None):
|
|||
|
||||
return ensure_future(coro_or_future, loop=loop)
|
||||
|
||||
# Silence DeprecationWarning:
|
||||
globals()['async'] = async_
|
||||
async_.__name__ = 'async'
|
||||
del async_
|
||||
|
||||
|
||||
def ensure_future(coro_or_future, *, loop=None):
|
||||
"""Wrap a coroutine or an awaitable in a future.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue