bpo-33672: Fix Task.__repr__ crash with Cython's bogus coroutines#7161
bpo-33672: Fix Task.__repr__ crash with Cython's bogus coroutines#71611st1 merged 2 commits intopython:masterfrom
Conversation
Lib/asyncio/coroutines.py
Outdated
There was a problem hiding this comment.
Do you have any insights into the conditions under which this can be observed? Is this a problem with older versions of Cython, or is there anything we can do to improve the situation?
There was a problem hiding this comment.
Not sure about __qualname__ and __name__, I got reports from uvloop users about this a couple of months ago. __code__ set to None should be easily reproducible with latest Cython -- ideally, __code__ should either be set to a code-like object or not set at all.
asvetlov
left a comment
There was a problem hiding this comment.
I have some minor questions and ideas for improvement.
Would be nice to address them before merging.
Lib/asyncio/coroutines.py
Outdated
There was a problem hiding this comment.
I don't follow why not push all this logic into format_helpers._format_callback?
There was a problem hiding this comment.
format_callback expects a Python function. This works on a coroutine object. This whole function should be moved to format_helpers.py though, I just don't want to do this in 3.7
Lib/asyncio/coroutines.py
Outdated
There was a problem hiding this comment.
No need a nested function here, top-level private _is_running is enough.
There was a problem hiding this comment.
I want to group all these functions somehow -- this whole formatting code should probably be rewritten or simplified in 3.8
Lib/asyncio/coroutines.py
Outdated
There was a problem hiding this comment.
From my perspective replacement running variable with explicit return coro.cr_running etc is more readable.
BTW when running is not bool?
There was a problem hiding this comment.
cr_running and gi_running should be bools or 0 or 1... So shouldn't be a problem.
asvetlov
left a comment
There was a problem hiding this comment.
LGTM.
I share the opinion that the code could be improved/rewritten but for sake of minimal Python 3.7 impact let's keep changes small.
Lib/asyncio/coroutines.py
Outdated
|
Thanks @1st1 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6. |
|
Thanks @1st1 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
|
Sorry, @1st1, I could not cleanly backport this to |
…thonGH-7161) (cherry picked from commit 989b9e0) Co-authored-by: Yury Selivanov <yury@magic.io>
|
GH-7173 is a backport of this pull request to the 3.7 branch. |
https://bugs.python.org/issue33672