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

Fix crash on access to local classes #2855

Merged
merged 2 commits into from
Feb 27, 2017

Conversation

ilevkivskyi
Copy link
Member

@ilevkivskyi ilevkivskyi commented Feb 12, 2017

Fixes #2559

The idea is the same as in PR #2553. The only difference is that mangled names are always stored in globals, otherwise there would be a problem for a method in a nested class that is itself inside a method.

@ilevkivskyi
Copy link
Member Author

@gvanrossum If you are curious, this monster still crashes when imported from elsewhere in incremental mode:

from typing import NamedTuple

class C:
    def f(self) -> None:
        class D:
            class E:
                def g(self) -> None:
                    A = NamedTuple('A', [('x', int), ('y', int)])
                    self.a = A(1, 1)
        self.c = D.E().a

This is why I made this PR to always use globals. Such approach is more robust against such deeply nested classes. In addition, always using globals simplifies code without risk of conflicts (since line numbers are unique anyway).

@JukkaL JukkaL merged commit ef6f156 into python:master Feb 27, 2017
@JukkaL
Copy link
Collaborator

JukkaL commented Feb 27, 2017

Thanks for the fix!

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