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

Catch the StopIteration that result from PEP-479 or add default value in next #1081

Merged
merged 2 commits into from
Jun 30, 2021

Conversation

Pierre-Sassoulas
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas commented Jun 30, 2021

StopIteration exceptions raised directly or indirectly in coroutines
and generators are transformed into RuntimeError exceptions for python
3.7+.

Description

Handle all the StopIteration and not just the one that caused pylint-dev/pylint#4631

Type of Changes

Type
🐛 Bug fix
🔨 Refactoring

Related Issue

Closes pylint-dev/pylint#4631
Closes #1080

@Pierre-Sassoulas Pierre-Sassoulas added blocker pylint-tested PRs that don't cause major regressions with pylint labels Jun 30, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.6.2 milestone Jun 30, 2021
StopIteration exceptions raised directly or indirectly in coroutines
and generators are transformed into RuntimeError exceptions for python
3.7+.
@Pierre-Sassoulas Pierre-Sassoulas linked an issue Jun 30, 2021 that may be closed by this pull request
@Pierre-Sassoulas
Copy link
Member Author

I'm going to merge as it's preventing crash and all pylint tests still work, but I'm still interested in a review if you think there's a more elegant way to do it :)

@Pierre-Sassoulas Pierre-Sassoulas merged commit 9e1af52 into master Jun 30, 2021
@Pierre-Sassoulas Pierre-Sassoulas deleted the handle-pep-479-in-next branch June 30, 2021 09:55
@cdce8p
Copy link
Member

cdce8p commented Jun 30, 2021

I'm not too familiar with the infer logic unfortunately. The only other way I can think of at the moment would be to make sure each infer method always returns an iterator and doesn't raise StopIteration on the first call of next. However that might be difficult to do, as we would need to understand and check every inference method.

@hippo91
Copy link
Contributor

hippo91 commented Jul 4, 2021

@Pierre-Sassoulas i think you did the right thing to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pylint-tested PRs that don't cause major regressions with pylint
Projects
None yet
3 participants