Skip to content

Always set correct kind for module __getattr__ #5893

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

Merged
merged 4 commits into from
Nov 15, 2018

Conversation

ilevkivskyi
Copy link
Member

Fixes #5866

There are two places where __getattr__ generated Vars are created, and somehow in one of them it was given a MDEF kind (which caused a crash), although it is a module attribute.

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Looks good, just one question about possible additional test case.

@@ -2627,3 +2627,35 @@ import foo.bar.baz
reveal_type(foo.bar.baz.x) # E: Revealed type is 'builtins.int'
[file foo/bar/baz.py]
x = 0

[case testModuleGetAttrAssignUnannotated]
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about testing a package with a missing explicit submodule (__getattr__ in __init__) and then assigning something to a submodule attribute? Or is this still unsupported?

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I added two tests for this.

@ilevkivskyi ilevkivskyi merged commit af5df38 into python:master Nov 15, 2018
@ilevkivskyi ilevkivskyi deleted the module-getattr-set-crash branch November 15, 2018 00:44
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.

2 participants