fix: pass __file__ to exec() in addon Init.py/InitGui.py loading #237
@@ -1204,7 +1204,7 @@ class DirMod(Mod):
|
||||
try:
|
||||
source = init_py.read_text(encoding="utf-8")
|
||||
code = compile(source, init_py, 'exec')
|
||||
exec(code)
|
||||
exec(code, {"__file__": str(init_py)})
|
||||
except Exception as ex:
|
||||
Log(f"Init: Initializing {self.path!s}... failed")
|
||||
Log(utils.HLine)
|
||||
|
||||
@@ -295,7 +295,7 @@ class DirModGui(ModGui):
|
||||
try:
|
||||
source = init_gui_py.read_text(encoding="utf-8")
|
||||
code = compile(source, init_gui_py, "exec")
|
||||
exec(code)
|
||||
exec(code, {"__file__": str(init_gui_py)})
|
||||
except Exception as ex:
|
||||
sep = "-" * 100 + "\n"
|
||||
Log(f"Init: Initializing {target!s}... failed\n")
|
||||
|
||||
Reference in New Issue
Block a user