Commit 6a200332 authored by Benoit Formet's avatar Benoit Formet
Browse files

user_script: export only objects from script in namespace

parent b59119a2
......@@ -524,8 +524,9 @@ class Session:
globals_dict = self.env_dict.copy()
c_code = compile(script, filepath, "exec")
exec(script, globals_dict)
exec(c_code, globals_dict)
except Exception:
......@@ -537,9 +538,11 @@ class Session:
elif return_namespace is True:
env_dict = dict()
for k in globals_dict.keys():
for k in c_code.co_names:
if k.startswith("_"):
if k not in globals_dict:
env_dict[k] = globals_dict[k]
return SimpleNamespace(**env_dict)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment