Message 321293 - Python tracker

Message321293

Author JDLH
Recipients JDLH, asvetlov, yselivanov
Date 2018-07-08.23:36:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1531093016.25.0.56676864532.issue34071@psf.upfronthosting.co.za>
In-reply-to
Content
This is what I observe when I run my original program with Python 3.7.0. Notice that the Task object instantiation fails with a clear error message:

% python -c 'import sys; print(sys.version)'
3.7.0 (default, Jun 28 2018, 06:01:52) 
[Clang 8.0.0 (clang-800.0.42.1)]

% python bug_task_repr_1.py            
type(ag()) is  <class 'async_generator'>
asyncio.iscoroutine(ag)?  False
repr(ag()) is  <async_generator object ag at 0x1081a7730>
Traceback (most recent call last):
  File "bug_task_repr_1.py", line 42, in <module>
    task = asyncio.get_event_loop().create_task(ag())
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 386, in create_task
    task = tasks.Task(coro, loop=self)
TypeError: a coroutine was expected, got <async_generator object ag at 0x1087cac80>

Also, the unit test example fails due to asyncio.test_utils no longer being present in Python 3.7.0. 

I am comfortable with a workaround of upgrading to 3.7.0 or later for anyone who encounters this problem. 

I file this bug report mostly to let people who encounter this problem find this report in web searches, to help them understand the cause, and  to see the workaround (patching Task._repr_info) if upgrading to 3.7 is not feasible.
History
Date User Action Args
2018-07-08 23:36:56JDLHsetrecipients: + JDLH, asvetlov, yselivanov
2018-07-08 23:36:56JDLHsetmessageid: <1531093016.25.0.56676864532.issue34071@psf.upfronthosting.co.za>
2018-07-08 23:36:56JDLHlinkissue34071 messages
2018-07-08 23:36:56JDLHcreate