Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator and coroutine repr could be more helpful #76650

Open
pitrou opened this issue Dec 31, 2017 · 3 comments
Open

Generator and coroutine repr could be more helpful #76650

pitrou opened this issue Dec 31, 2017 · 3 comments
Labels
3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@pitrou
Copy link
Member

pitrou commented Dec 31, 2017

BPO 32469
Nosy @pitrou, @benjaminp, @serhiy-storchaka, @1st1, @tarasmatsyk
PRs
  • bpo-32469: Improve representation of the coroutines #5068
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2017-12-31.19:53:29.096>
    labels = ['interpreter-core', 'type-feature', '3.8']
    title = 'Generator and coroutine repr could be more helpful'
    updated_at = <Date 2018-06-11.07:52:58.314>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2018-06-11.07:52:58.314>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2017-12-31.19:53:29.096>
    creator = 'pitrou'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32469
    keywords = ['patch']
    message_count = 3.0
    messages = ['309302', '309315', '319280']
    nosy_count = 5.0
    nosy_names = ['pitrou', 'benjamin.peterson', 'serhiy.storchaka', 'yselivanov', 'tarasmatsyk']
    pr_nums = ['5068']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue32469'
    versions = ['Python 3.8']

    @pitrou
    Copy link
    Member Author

    pitrou commented Dec 31, 2017

    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)

    @pitrou pitrou added the 3.7 (EOL) end of life label Dec 31, 2017
    @tarasmatsyk
    Copy link
    Mannequin

    tarasmatsyk mannequin commented Dec 31, 2017

    I have added a pull request. Hope it makes sense and I've done everything correctly :)

    Happy New Year!

    @serhiy-storchaka
    Copy link
    Member

    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.

    @serhiy-storchaka serhiy-storchaka added interpreter-core (Objects, Python, Grammar, and Parser dirs) 3.8 only security fixes type-feature A feature request or enhancement and removed 3.7 (EOL) end of life labels Jun 11, 2018
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants