Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Eval of code objects does not always fill passed locals dictionary #132148

Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or error
@lejar

Description

@lejar

Bug report

Bug description:

When passing a code object to the eval (doc) builtin, I am observing that the locals dictionary is not always filled with the variables created inside of the code. For example:

importtextwrapdeffoo_func():a=1b=2foo_str=compile(textwrap.dedent("""\        a = 1        b = 2        """    ),'<file>','exec',)glb=globals()loc= {}eval(foo_func.__code__,glb,loc)print('foo_func',loc)eval(foo_str,glb,loc)print('foo_str',loc)

produces the output:

foo_func {}
foo_str {'a': 1, 'b': 2}

I would expect the output to be the same for both calls.

CPython versions tested on:

3.13

Operating systems tested on:

Linux, macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp