Skip to content

bpo-32636: Fix @asyncio.coroutine debug mode bug exposed by #5250 #5291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Lib/asyncio/coroutines.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ def coro(*args, **kw):
res = yield from await_meth()
return res

coro = types.coroutine(coro)
if not _DEBUG:
wrapper = types.coroutine(coro)
wrapper = coro
else:
@functools.wraps(func)
def wrapper(*args, **kwds):
Expand Down
17 changes: 17 additions & 0 deletions Lib/test/test_asyncio/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import random
import re
import sys
import textwrap
import types
import unittest
import weakref
Expand Down Expand Up @@ -3112,6 +3113,22 @@ async def inner():
result = self.loop.run_until_complete(inner())
self.assertEqual(['ok1', 'ok2'], result)

def test_debug_mode_interop(self):
# https://bugs.python.org/issue32636
code = textwrap.dedent("""
import asyncio

async def native_coro():
pass

@asyncio.coroutine
def old_style_coro():
yield from native_coro()

asyncio.run(old_style_coro())
""")
assert_python_ok("-c", code, PYTHONASYNCIODEBUG="1")


if __name__ == '__main__':
unittest.main()