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
variable resolution within exec() incorrect #53065
Comments
A discussion on stack overflow - http://stackoverflow.com/questions/2904274/globals-and-locals-in-python-exec - has led to the conclusion that the variable lookup behaviour within code run using exec() is not behaving as expected. Variable lookup inside a class definition does not search the enclosing scope's locals() prior to issuing a NameError - there are full details and test cases at the above URL. |
This looks like a duplicate of bpo-991196. |
Judging by the bpo-991196 discussion, the described behaviour is intentional. In particular, this behaviour isn't likely to change in Python 2.x: 2.6 is in bugfix only mode, and 2.7 is too close to release to start messing with internals. You may be able to make an argument that the behaviour should be changed in Python 3.x; that discussion should happen on python-dev or python-ideas rather than on the tracker, though. |
Agreed, this is the same issue. I'll make my argument that this is a bug (intentional or otherwise) on that issue. |
Apologies for raising it in the tracker against your advice. My thinking was that you were suggesting discussions about 3.x content shouldn't be in the tracker, and I wanted to argue that it is a bug and should be fixed in 2.6+ |
Hmm. To get this changed in 2.x you'd have to convince people that it really is a bug. You probably also need to do that very soon for there to be any hope of 2.7 having changed behaviour. I'd suggest bringing this up on the python-dev mailing list; it'll get better visibility there. If you can describe exactly what should change (and even better, how that change might be implemented) that would be a bonus. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: