KEMBAR78
Never put None in TupleType items by ilevkivskyi · Pull Request #4051 · python/mypy · GitHub
Skip to content

Conversation

ilevkivskyi
Copy link
Member

Fixes #4046

The root cause for the crash is that None was put in TupleType items if the corresponding lvalue is a definition. Then the crash happens when this TupleType is used as a context for rvalue type inference. The solution is to put UninhabitedType in such cases, so that inference will fall back on using argument types instead.

This PR should not cause any crashes but it makes sense to test it against internal codebases since it touches an area that might alter type inference in corner cases.

Copy link
Member

@emmatyping emmatyping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks good to me as long as it works for @ambv / @carljm.

@gvanrossum gvanrossum merged commit d23fc47 into python:master Oct 3, 2017
@gvanrossum
Copy link
Member

I checked our internal codebase and everything's fine. Thanks for the quick fix! I'll ponder it a little bit and then probably cherry-pick.

@gvanrossum gvanrossum mentioned this pull request Oct 3, 2017
5 tasks
@carljm
Copy link
Member

carljm commented Oct 3, 2017

This fixes the issue for us as well. Thanks @ilevkivskyi!

@ilevkivskyi ilevkivskyi deleted the fix-nested-tuples branch October 20, 2017 23:06
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.

4 participants