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

@ -253,12 +253,10 @@ class EventLoopTestsMixin:
super().tearDown()
def test_run_until_complete_nesting(self):
@asyncio.coroutine
def coro1():
yield
async def coro1():
await asyncio.sleep(0)
@asyncio.coroutine
def coro2():
async def coro2():
self.assertTrue(self.loop.is_running())
self.loop.run_until_complete(coro1())
@ -735,8 +733,7 @@ class EventLoopTestsMixin:
@mock.patch('asyncio.base_events.socket')
def create_server_multiple_hosts(self, family, hosts, mock_sock):
@asyncio.coroutine
def getaddrinfo(host, port, *args, **kw):
async def getaddrinfo(host, port, *args, **kw):
if family == socket.AF_INET:
return [(family, socket.SOCK_STREAM, 6, '', (host, port))]
else:
@ -1662,8 +1659,7 @@ class EventLoopTestsMixin:
loop.add_writer(w, callback)
def test_close_running_event_loop(self):
@asyncio.coroutine
def close_loop(loop):
async def close_loop(loop):
self.loop.close()
coro = close_loop(self.loop)
@ -1673,8 +1669,7 @@ class EventLoopTestsMixin:
def test_close(self):
self.loop.close()
@asyncio.coroutine
def test():
async def test():
pass
func = lambda: False
@ -2142,7 +2137,8 @@ class HandleTests(test_utils.TestCase):
'<Handle cancelled>')
# decorated function
cb = asyncio.coroutine(noop)
with self.assertWarns(DeprecationWarning):
cb = asyncio.coroutine(noop)
h = asyncio.Handle(cb, (), self.loop)
self.assertEqual(repr(h),
'<Handle noop() at %s:%s>'