Skip to content

Commit fb5a7ad

Browse files
njsmith1st1
authored andcommitted
bpo-32636: Fix @asyncio.coroutine debug mode bug exposed by gh-5250 (#5291)
1 parent 0a5e71b commit fb5a7ad

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Lib/asyncio/coroutines.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ def coro(*args, **kw):
132132
res = yield from await_meth()
133133
return res
134134

135+
coro = types.coroutine(coro)
135136
if not _DEBUG:
136-
wrapper = types.coroutine(coro)
137+
wrapper = coro
137138
else:
138139
@functools.wraps(func)
139140
def wrapper(*args, **kwds):

Lib/test/test_asyncio/test_tasks.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import random
1010
import re
1111
import sys
12+
import textwrap
1213
import types
1314
import unittest
1415
import weakref
@@ -3090,6 +3091,22 @@ async def inner():
30903091
result = self.loop.run_until_complete(inner())
30913092
self.assertEqual(['ok1', 'ok2'], result)
30923093

3094+
def test_debug_mode_interop(self):
3095+
# https://bugs.python.org/issue32636
3096+
code = textwrap.dedent("""
3097+
import asyncio
3098+
3099+
async def native_coro():
3100+
pass
3101+
3102+
@asyncio.coroutine
3103+
def old_style_coro():
3104+
yield from native_coro()
3105+
3106+
asyncio.run(old_style_coro())
3107+
""")
3108+
assert_python_ok("-c", code, PYTHONASYNCIODEBUG="1")
3109+
30933110

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

0 commit comments

Comments
 (0)