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

Shouldn't For.iter be evaluated in the parent frame? #518

Closed
damz opened this issue Dec 10, 2015 · 1 comment
Closed

Shouldn't For.iter be evaluated in the parent frame? #518

damz opened this issue Dec 10, 2015 · 1 comment

Comments

@damz
Copy link

damz commented Dec 10, 2015

Context: I'm trying to write an introspection that finds all the chains of Getitem or Getattr that start with an undefined Name. Like jinja2.find_undeclared_variables but that goes deeper into attribute chains when it's easy to do.

Now, I'm seeing that For.iter is visited within loop_frame, which doesn't make sense to me, as the loop_frame is defined as the frame of everything except iter:

children = node.iter_child_nodes(exclude=('iter',))
if node.recursive:
    loop_frame = self.function_scoping(node, frame, children,
                                       find_special=False)
else:
    loop_frame = frame.inner()
    loop_frame.inspect(children)

Can you confirm this is a bug that can be fixed?

@mitsuhiko
Copy link
Contributor

I think this should no longer happen with the cleaned up identifier tracking.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants