We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
eval
exec
1 parent a5fbef8 commit 29b6baeCopy full SHA for 29b6bae
python/pythonmonkey/require.py
@@ -82,8 +82,11 @@
82
globalThis.python.stderr.write = lambda s: sys.stderr.write(s)
83
globalThis.python.stdout.read = lambda n: sys.stdout.read(n)
84
globalThis.python.stderr.read = lambda n: sys.stderr.read(n)
85
-globalThis.python.eval = eval
86
-globalThis.python.exec = exec
+# Python 3.13 dramatically changed how the namespace in `exec`/`eval` works
+# See https://docs.python.org/3.13/whatsnew/3.13.html#defined-mutation-semantics-for-locals
87
+_locals = {} # keep the local variables inside `eval`/`exec` to a dict
88
+globalThis.python.eval = lambda x: eval(x, None, _locals)
89
+globalThis.python.exec = lambda x: exec(x, None, _locals)
90
globalThis.python.getenv = os.getenv
91
globalThis.python.paths = sys.path
92
0 commit comments