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

[regression] symtable.Symbol.is_local() is no longer True for bound global symbols #86006

Closed
CendioOssman mannequin opened this issue Sep 23, 2020 · 5 comments
Closed
Labels
3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir

Comments

@CendioOssman
Copy link
Mannequin

CendioOssman mannequin commented Sep 23, 2020

BPO 41840
Nosy @pablogsal, @CendioOssman
PRs
  • bpo-41840: Report module-level globals as both local and global in the symtable module #22391
  • [3.9] bpo-41840: Report module-level globals as both local and global in the symtable module (GH-22391) #22528
  • [3.8] bpo-41840: Report module-level globals as both local and global in the symtable module (GH-22391) #22529
  • 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 2020-10-03.21:49:56.503>
    created_at = <Date 2020-09-23.12:22:04.951>
    labels = ['3.8', '3.7', 'library', '3.9', '3.10']
    title = '[regression] symtable.Symbol.is_local() is no longer True for bound global symbols'
    updated_at = <Date 2020-10-03.21:50:03.298>
    user = 'https://github.com/CendioOssman'

    bugs.python.org fields:

    activity = <Date 2020-10-03.21:50:03.298>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-10-03.21:49:56.503>
    closer = 'pablogsal'
    components = ['Library (Lib)']
    creation = <Date 2020-09-23.12:22:04.951>
    creator = 'CendioOssman'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41840
    keywords = ['patch']
    message_count = 5.0
    messages = ['377373', '377428', '377901', '377903', '377904']
    nosy_count = 2.0
    nosy_names = ['pablogsal', 'CendioOssman']
    pr_nums = ['22391', '22528', '22529']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue41840'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10']

    @CendioOssman
    Copy link
    Mannequin Author

    CendioOssman mannequin commented Sep 23, 2020

    So bpo-40196 (and PR 19391) broke things for us here as Symbol.is_local() no longer works properly for symbols on the global/module scope.

    Previously it would return True for all global symbols that were bound. Now it only returns True when the symbol is not used in any other scope. This means we cannot tell the difference between globals that are from the module itself, and globals that come in via imports.

    This also seems to contradict this part of the language reference:

    "(The variables of the module code block are local and global.)"

    https://docs.python.org/3/reference/executionmodel.html

    I don't see any clean workaround as there is no Symbol.is_bound() that could be used instead.

    (inb4 https://xkcd.com/1172/)

    @CendioOssman CendioOssman mannequin added 3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir labels Sep 23, 2020
    @pablogsal
    Copy link
    Member

    Hi Cendio Ossman and thanks for the report.

    Indeed, there are a bunch of problems here taking into account the language reference "The variables of the module code block are local and global". PR 22391 fixes those and also the repr-generation for module-level that was also broken

    @pablogsal
    Copy link
    Member

    New changeset fb0a465 by Pablo Galindo in branch 'master':
    bpo-41840: Report module-level globals as both local and global in the symtable module (GH-22391)
    fb0a465

    @pablogsal
    Copy link
    Member

    New changeset 7b7aa94 by Pablo Galindo in branch '3.9':
    [3.9] bpo-41840: Report module-level globals as both local and global in the symtable module (GH-22391). (GH-22528)
    7b7aa94

    @pablogsal
    Copy link
    Member

    New changeset fd22823 by Pablo Galindo in branch '3.8':
    [3.8] bpo-41840: Report module-level globals as both local and global in the symtable module (GH-22391). (GH-22529)
    fd22823

    @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
    3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant