bpo-36921: Deprecate @coroutine for sake of async def (GH-13346)

The second attempt. Now deprecate `@coroutine` only, keep `yield from fut` as is.


https://bugs.python.org/issue36921
This commit is contained in:
Andrew Svetlov 2019-05-16 17:52:10 +03:00 committed by Miss Islington (bot)
parent dbacfc2273
commit 68b34a7204
12 changed files with 311 additions and 320 deletions

View file

@ -7,6 +7,7 @@ import os
import sys
import traceback
import types
import warnings
from . import base_futures
from . import constants
@ -107,6 +108,9 @@ def coroutine(func):
If the coroutine is not yielded from before it is destroyed,
an error message is logged.
"""
warnings.warn('"@coroutine" decorator is deprecated since Python 3.8, use "async def" instead',
DeprecationWarning,
stacklevel=2)
if inspect.iscoroutinefunction(func):
# In Python 3.5 that's all we need to do for coroutines
# defined with "async def".