Skip to content

Conversation

@AnonymDevOSS
Copy link
Contributor

The loop never uses break, so the else clause always executes. However, since it iterates over a generator, the generator is already exhausted after the first pass... so the else block would iterate over nothing.

So, i believe the 'else' is redundant.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How has this change been tested, please provide a testcase or example of how you tested the change?

>>> def g():
...   for x in range(3):
...     yield x
... 
>>> gen = g()
>>> for x in gen:
...   print(x)
... else:
...   for y in gen:
...     print("y", y)
... 
0
1
2

Any specific deployment considerations

For example, documentation changes, usability, usage/costs, secrets, etc.

Docs

  • Docs updated? What were the changes:

@CLAassistant
Copy link

CLAassistant commented Oct 26, 2025

CLA assistant check
All committers have signed the CLA.

The loop never uses break, so the else clause always executes.
However, since it iterates over a generator, the generator is already exhausted after the first pass... so the else block would iterate over nothing.

So, i believe the 'else' is redundant.
@Borda Borda added the bug Something isn't working label Jan 26, 2026
@Borda
Copy link
Member

Borda commented Jan 26, 2026

@AnonymDevOSS, thank you for your effort and for helping to resolve this issue. Regarding the progress and still some non-trivial path to be finished, we will proseed with #2022

@Borda Borda closed this Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working has conflicts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants