This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Generator and coroutine repr could be more helpful
Type: enhancement Stage: patch review
Components: Interpreter Core Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, pitrou, serhiy.storchaka, tarasmatsyk, yselivanov
Priority: normal Keywords: patch

Created on 2017-12-31 19:53 by pitrou, last changed 2022-04-11 14:58 by admin.

Pull Requests
URL Status Linked Edit
PR 5068 closed tarasmatsyk, 2017-12-31 22:13
Messages (3)
msg309302 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-12-31 19:53
Currently, a generator or coroutine's repr looks like this:

>>> gen
<coroutine object f at 0x7f86c9733790>

It could instead be something like:

>>> gen
<coroutine at 0x7f86c9733790, suspended, file "/home/antoine/cpython/default/Lib/logging/__init__.py", line 123, code getLogger>

(replace "suspended" with "running" or "closed" depending on the generator's status -- i.e. gi_running and gi_frame attributes)
msg309315 - (view) Author: Taras Matsyk (tarasmatsyk) * Date: 2017-12-31 22:14
I have added a pull request. Hope it makes sense and I've done everything correctly :)

Happy New Year!
msg319280 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-11 07:52
Isn't it too verbose? For comparison, the repr of function doesn't contain the file path and the line number. And the hexadecimal address in the middle looks distractive.
History
Date User Action Args
2022-04-11 14:58:56adminsetgithub: 76650
2018-06-11 07:52:58serhiy.storchakasettype: enhancement
messages: + msg319280
components: + Interpreter Core
versions: + Python 3.8, - Python 3.7
2017-12-31 22:14:58tarasmatsyksetnosy: + tarasmatsyk
messages: + msg309315
2017-12-31 22:13:14tarasmatsyksetkeywords: + patch
stage: patch review
pull_requests: + pull_request4942
2017-12-31 19:53:29pitroucreate