Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

closing async_generator_athrow on an async generator that suppresses GeneratorExit does not raise RuntimeError #117714

Closed
Labels
3.12only security fixes3.13bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
@graingert

Description

@graingert

Bug report

Bug description:

when runningagen.aclose().close() it should throw GeneratorExit into the coroutine and raise RuntimeError from.close():

importtypes@types.coroutinedef_async_yield(v):return (yieldv)asyncdefagenfn():try:yield1finally:try:await_async_yield(2)exceptGeneratorExit:print("generator exit")await_async_yield(3)agen=agenfn()try:anext(agen).send(None)exceptStopIterationase:print(e.value)try:agen.aclose().close()exceptRuntimeError:print("good")else:print("bad")

prints:

1badException ignored in: <async_generator object agenfn at 0x7e0c43b09620>RuntimeError: async generator ignored GeneratorExit

CPython versions tested on:

3.11, 3.12, 3.13, CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp