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

PyAsyncGenObject causes task.get_stack() raising AttributeError #83945

Closed
lidizheng mannequin opened this issue Feb 26, 2020 · 3 comments
Closed

PyAsyncGenObject causes task.get_stack() raising AttributeError #83945

lidizheng mannequin opened this issue Feb 26, 2020 · 3 comments
Labels
3.9 only security fixes topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@lidizheng
Copy link
Mannequin

lidizheng mannequin commented Feb 26, 2020

BPO 39764
Nosy @asvetlov, @1st1, @miss-islington, @lidizheng
PRs
  • bpo-39764: Make Task.get_stack accept ag_frame #18669
  • [3.8] bpo-39764: Make Task.get_stack accept ag_frame (GH-18669) #18742
  • 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 = <Date 2020-03-02.13:06:37.014>
    created_at = <Date 2020-02-26.19:25:53.231>
    labels = ['type-bug', '3.9', 'expert-asyncio']
    title = 'PyAsyncGenObject causes task.get_stack() raising AttributeError'
    updated_at = <Date 2020-03-02.13:06:37.013>
    user = 'https://github.com/lidizheng'

    bugs.python.org fields:

    activity = <Date 2020-03-02.13:06:37.013>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-03-02.13:06:37.014>
    closer = 'asvetlov'
    components = ['asyncio']
    creation = <Date 2020-02-26.19:25:53.231>
    creator = 'lidiz'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39764
    keywords = ['patch']
    message_count = 3.0
    messages = ['362722', '363168', '363170']
    nosy_count = 4.0
    nosy_names = ['asvetlov', 'yselivanov', 'miss-islington', 'lidiz']
    pr_nums = ['18669', '18742']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue39764'
    versions = ['Python 3.9']

    @lidizheng
    Copy link
    Mannequin Author

    lidizheng mannequin commented Feb 26, 2020

    This issue exists since 3.6.

    The implementation of get stack on Task is looking for two attribute [1]: "cr_frame" for coroutines, "gi_frame" for generators (legacy coroutines). However, PyAsyncGenObject provides none of them but "ag_frame" [2].

    Fix PR: #18669

    A simple reproduce:

        def test_async_gen_aclose_compatible_with_get_stack(self):
            async def async_generator():
                yield object()
    
            async def run():
                ag = async_generator()
                asyncio.create_task(ag.aclose())
                tasks = asyncio.all_tasks()
                for task in tasks:
                    # No AttributeError raised
                    task.get_stack()
        self.loop.run_until_complete
    

    I found this in my project I want to view who created the Tasks.

    [1]


    [2]
    {"ag_frame", T_OBJECT, offsetof(PyAsyncGenObject, ag_frame), READONLY},

    @lidizheng lidizheng mannequin added 3.9 only security fixes topic-asyncio type-bug An unexpected behavior, bug, or error labels Feb 26, 2020
    @asvetlov
    Copy link
    Contributor

    asvetlov commented Mar 2, 2020

    New changeset 4482337 by Lidi Zheng in branch 'master':
    bpo-39764: Make Task.get_stack accept ag_frame (bpo-18669)
    4482337

    @miss-islington
    Copy link
    Contributor

    New changeset 43932dc by Miss Islington (bot) in branch '3.8':
    bpo-39764: Make Task.get_stack accept ag_frame (GH-18669)
    43932dc

    @asvetlov asvetlov closed this as completed Mar 2, 2020
    @asvetlov asvetlov closed this as completed Mar 2, 2020
    @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.9 only security fixes topic-asyncio type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants