Skip to content

Conversation

@david-yz-liu
Copy link
Contributor

Steps

  • For new features or bug fixes, add a ChangeLog entry describing what your PR does.
  • Write a good description on what the PR does.

Description

This fixes pylint-dev/pylint#3274. Prior to Python 3.7, StopIteration errors bubbled up through generators, so this wasn't an issue for astroid because the StopIteration error was handled later. Now StopIteration errors are converted to RuntimeErrors (PEP 479), so the same error handling doesn't work.

Note: based on the above issue, I was able to come up with a minimal code example where calling .inferred() raises an error on Python 3.7+ (see the test I added), but I wasn't actually able to determine out why a StopIteration error occurred at all. I'm not familiar enough with astroid's inference to tell whether raising StopIteration is the intended behaviour or not, so there might be a better fix.

Type of Changes

Type
🐛 Bug fix

This fixes pylint-dev/pylint#3274.
Prior to Python 3.7, StopIteration errors bubbled up through generators,
so this wasn't an issue for astroid because the StopIteration error was
handled later. Now StopIteration errors are converted to RuntimeErrors
[1],
so the same error handling doesn't work.

[1]: https://www.python.org/dev/peps/pep-0479/
@PCManticore
Copy link
Contributor

Thanks for the PR @david-yz-liu !

@PCManticore PCManticore merged commit 18ca60d into pylint-dev:master Dec 9, 2019
@david-yz-liu david-yz-liu deleted the infer_int_stop_iteration branch December 9, 2019 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runtime error (StopIteration) due to _inference_tip_cached KeyError under py3.7 but not py3.6

2 participants