[Python-checkins] cpython (merge 3.6 -> default): Merge 3.6 (asyncio)
yury.selivanov
python-checkins at python.org
Tue Nov 8 19:16:43 EST 2016
https://hg.python.org/cpython/rev/8e472e85fa5e
changeset: 104995:8e472e85fa5e
parent: 104992:b977775aa07d
parent: 104994:0943453c0210
user: Yury Selivanov <yury at magic.io>
date: Tue Nov 08 19:16:37 2016 -0500
summary:
Merge 3.6 (asyncio)
files:
Lib/asyncio/coroutines.py | 8 ++++++--
Lib/test/test_asyncio/test_events.py | 8 ++++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/Lib/asyncio/coroutines.py b/Lib/asyncio/coroutines.py
--- a/Lib/asyncio/coroutines.py
+++ b/Lib/asyncio/coroutines.py
@@ -262,8 +262,12 @@
assert iscoroutine(coro)
if not hasattr(coro, 'cr_code') and not hasattr(coro, 'gi_code'):
- # Most likely a Cython coroutine.
- coro_name = getattr(coro, '__qualname__', coro.__name__)
+ # Most likely a built-in type or a Cython coroutine.
+
+ # Built-in types might not have __qualname__ or __name__.
+ coro_name = getattr(
+ coro, '__qualname__',
+ getattr(coro, '__name__', type(coro).__name__))
coro_name = '{}()'.format(coro_name)
running = False
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -2384,8 +2384,6 @@
# (such as ones compiled with Cython).
class Coro:
- __name__ = 'AAA'
-
def send(self, v):
pass
@@ -2399,6 +2397,7 @@
pass
coro = Coro()
+ coro.__name__ = 'AAA'
self.assertTrue(asyncio.iscoroutine(coro))
self.assertEqual(coroutines._format_coroutine(coro), 'AAA()')
@@ -2408,6 +2407,11 @@
coro.cr_running = True
self.assertEqual(coroutines._format_coroutine(coro), 'BBB() running')
+ coro = Coro()
+ # Some coroutines might not have '__name__', such as
+ # built-in async_gen.asend().
+ self.assertEqual(coroutines._format_coroutine(coro), 'Coro()')
+
class TimerTests(unittest.TestCase):
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list