8000 `generator.close()` never raises `GeneratorExit` · Issue #135110 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
generator.close() never raises GeneratorExit #135110
Closed
@hyperkai

Description

@hyperkai

Bug report

Bug description:

The doc of generator.close() says as shown below:

Raises a GeneratorExit at the point where the generator function was paused.

But generator.close() nev 7D23 er raises GeneratorExit as shown below:

def func():
    yield 'Hello'
    yield 'World'

v = func()

print(v.close()) # None
print(v.close()) # None
def func():
    yield 'Hello'
    yield 'World'

v = func()

print(next(v)) # Hello

print(v.close()) # None
print(v.close()) # None
def func():
    yield 'Hello'
    yield 'World'

v = func()

print(next(v)) # Hello
print(next(v)) # World

print(v.close()) # None
print(v.close()) # None
def func():
    yield 'Hello'
    yield 'World'

v = func()

print(v.close()) # None

print(next(v)) # StopIteration
def func():
    yield 'Hello'
    yield 'World'

v = func()

print(next(v)) # Hello

print(v.close()) # None

print(next(v)) # StopIteration

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc direasy

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0