Commit afb2221a authored by Benoit Formet's avatar Benoit Formet
Browse files

session: set __file__ before load script and setup

parent a6d4f94f
Pipeline #22167 failed with stages
in 16 minutes and 41 seconds
......@@ -403,6 +403,7 @@ class Session:
c_code = compile(s_code, filename, "exec")
globals_dict = self.env_dict.copy()
globals_dict["__file__"] = filename
try:
exec(c_code, globals_dict)
except Exception:
......@@ -529,6 +530,7 @@ class Session:
print(f"Running [{filepath}]...")
globals_dict = self.env_dict.copy()
globals_dict["__file__"] = filepath
c_code = compile(script, filepath, "exec")
try:
......@@ -628,9 +630,13 @@ class Session:
else:
env_dict["load_script"] = self.load_script
_file_ = env_dict["__file__"]
env_dict["__file__"] = self.setup_file
code = compile(setup_file.read(), self.setup_file, "exec")
exec(code, env_dict)
env_dict["__file__"] = _file_
for obj_name, obj in env_dict.items():
setattr(setup_globals, obj_name, obj)
......
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