py/builtinevex: Fix setting globals for native functions in compile().

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2024-02-20 11:41:04 +11:00
parent 916ceecaef
commit 3db29103a4
2 changed files with 10 additions and 3 deletions

View File

@@ -29,6 +29,9 @@ def test():
exec(compile("print(10 + 2)", "file", "single"))
print(eval(compile("10 + 3", "file", "eval")))
# test accessing a function's globals from within a compile
exec(compile("def func():pass\nprint('x', func.__globals__['x'])", "file", "exec"))
# bad mode
try:
compile('1', 'file', '')