Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

NameError: Add new test case/regexp #20

Open
SylvainDe opened this issue Feb 27, 2016 · 1 comment
Open

NameError: Add new test case/regexp #20

SylvainDe opened this issue Feb 27, 2016 · 1 comment

Comments

@SylvainDe
Copy link
Owner

Got add different error message

NameError: free variable 'title' referenced before assignment in enclosing scope

$ python --version
Python 3.2.3

SylvainDe added a commit that referenced this issue Feb 27, 2016
I stumbled upon an unusual NameError and thought I'd
wrote it down for later.

This test will most likely fail with other intepreters.
@SylvainDe
Copy link
Owner Author

Suggestion:

@register_suggestion_for(NameError, re.VARREFBEFOREASSIGN_RE)
def suggest_local_var_ref_before_assign(value, frame, groups):
    """Get the suggestions for local var reference before assign."""
    del value  # unused param
    name, = groups
    objs = get_objects_in_frame(frame).get(name, [])
    for obj, scope in objs:
        # TODO_ENCLOSING: suggest 'nonlocal'
        if scope == 'global':
            return
            yield quote('global ' + name)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant