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

This commit is contained in:
Nathaniel J. Smith 2018-01-24 12:14:33 -08:00 committed by Yury Selivanov
parent 0a5e71b4c7
commit fb5a7ad421
2 changed files with 19 additions and 1 deletions

View File

@ -132,8 +132,9 @@ def coroutine(func):
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):

View File

@ -9,6 +9,7 @@ import io
import random
import re
import sys
import textwrap
import types
import unittest
import weakref
@ -3090,6 +3091,22 @@ class CompatibilityTests(test_utils.TestCase):
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()