Skip to content

LocalsDictionary not generated in certain cases #562

@slozier

Description

@slozier
a = locals
def test():
    return a()

assert test() == {}

It looks like there's an optimization to only create a locals dictionary when needed. However the way it determines if it's needed is by looking at the name of the call expression (see IronPython.Compiler.Ast.CallExpression.NeedsLocalsDictionary). NeedsLocalsDictionary returns false in the example above.

Similarly this will also fail for dir, vars, eval and exec...

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreIssues relating to core functionality (e.g. syntax)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions