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

variable resolution within exec() incorrect #53065

Closed
hawkett mannequin opened this issue May 25, 2010 · 6 comments
Closed

variable resolution within exec() incorrect #53065

hawkett mannequin opened this issue May 25, 2010 · 6 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@hawkett
Copy link
Mannequin

hawkett mannequin commented May 25, 2010

BPO 8819
Nosy @mdickinson
Superseder
  • bpo-991196: An inconsistency with nested scopes
  • 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:

    assignee = None
    closed_at = <Date 2010-05-25.18:53:02.925>
    created_at = <Date 2010-05-25.16:49:06.697>
    labels = ['type-bug']
    title = 'variable resolution within exec() incorrect'
    updated_at = <Date 2010-05-26.08:49:50.814>
    user = 'https://bugs.python.org/hawkett'

    bugs.python.org fields:

    activity = <Date 2010-05-26.08:49:50.814>
    actor = 'mark.dickinson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-05-25.18:53:02.925>
    closer = 'mark.dickinson'
    components = ['None']
    creation = <Date 2010-05-25.16:49:06.697>
    creator = 'hawkett'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 8819
    keywords = []
    message_count = 6.0
    messages = ['106447', '106451', '106464', '106510', '106515', '106516']
    nosy_count = 2.0
    nosy_names = ['mark.dickinson', 'hawkett']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '991196'
    type = 'behavior'
    url = 'https://bugs.python.org/issue8819'
    versions = ['Python 2.6']

    @hawkett
    Copy link
    Mannequin Author

    hawkett mannequin commented May 25, 2010

    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.

    @hawkett hawkett mannequin added the type-bug An unexpected behavior, bug, or error label May 25, 2010
    @mdickinson
    Copy link
    Member

    This looks like a duplicate of bpo-991196.

    @mdickinson
    Copy link
    Member

    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.

    @hawkett
    Copy link
    Mannequin Author

    hawkett mannequin commented May 26, 2010

    Agreed, this is the same issue. I'll make my argument that this is a bug (intentional or otherwise) on that issue.

    @hawkett
    Copy link
    Mannequin Author

    hawkett mannequin commented May 26, 2010

    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+

    @mdickinson
    Copy link
    Member

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant