This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年05月25日 16:49 by hawkett, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (6) | |||
|---|---|---|---|
| msg106447 - (view) | Author: Colin Hawkett (hawkett) | Date: 2010年05月25日 16:49 | |
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. |
|||
| msg106451 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2010年05月25日 17:15 | |
This looks like a duplicate of issue 991196. |
|||
| msg106464 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2010年05月25日 18:53 | |
Judging by the issue 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. |
|||
| msg106510 - (view) | Author: Colin Hawkett (hawkett) | Date: 2010年05月26日 07:09 | |
Agreed, this is the same issue. I'll make my argument that this is a bug (intentional or otherwise) on that issue. |
|||
| msg106515 - (view) | Author: Colin Hawkett (hawkett) | Date: 2010年05月26日 08:41 | |
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+ |
|||
| msg106516 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2010年05月26日 08:49 | |
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. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:01 | admin | set | github: 53065 |
| 2010年05月26日 08:49:50 | mark.dickinson | set | messages: + msg106516 |
| 2010年05月26日 08:41:47 | hawkett | set | messages: + msg106515 |
| 2010年05月26日 07:09:58 | hawkett | set | messages: + msg106510 |
| 2010年05月25日 18:53:02 | mark.dickinson | set | status: open -> closed resolution: duplicate superseder: An inconsistency with nested scopes messages: + msg106464 |
| 2010年05月25日 17:15:17 | mark.dickinson | set | nosy:
+ mark.dickinson messages: + msg106451 |
| 2010年05月25日 16:49:06 | hawkett | create | |