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

handle del inside function definition #467

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Hanaasagi
Copy link
Contributor

@Hanaasagi Hanaasagi commented Sep 4, 2019

It will resolve #428.

a = 1

def test():
    a = 2
    del a
    print(a)

test()

handleNodeLoad will always search the name a from function scope to module scope, even if we defined a same name in function and then delete it. We need to remember the name we deleted. Because of name shadowing, Python will not search the outer scope.

@Hanaasagi Hanaasagi marked this pull request as ready for review September 5, 2019 13:49
@Hanaasagi
Copy link
Contributor Author

Know little about PyPy, it's behavior is different from Python 😂

@asottile
Copy link
Member

asottile commented Sep 5, 2019

looks like new versions of pypy have different offsets, I'll make a PR to fix that -- should be unrelated to your change here 👍

@Hanaasagi Hanaasagi changed the title Fix issue 428 handle del inside function definition Sep 29, 2019
@Hanaasagi
Copy link
Contributor Author

Hanaasagi commented Jul 1, 2021

Hello, are there any questions about this PR?

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.

Pyflakes doesn't properly handle del inside function definition
2 participants