fix: pass __file__ to exec() in addon Init.py/InitGui.py loading #237

Merged
forbes merged 1 commits from fix/addon-init-file-variable into main 2026-02-15 03:28:28 +00:00

1 Commits

Author SHA1 Message Date
forbes
e10841a6c8 fix: pass __file__ to exec() in addon Init.py/InitGui.py loading
Some checks failed
Build and Test / build (pull_request) Has been cancelled
DirMod.run_init() and DirModGui.run_init_gui() use exec(code) to run
addon Init.py and InitGui.py files, but don't pass __file__ in the
globals dict. Addons that reference __file__ (e.g. Silo) crash with
NameError: name '__file__' is not defined.

Pass {"__file__": str(init_py)} as the globals argument so __file__
is available in the executed code, matching the behavior of normal
Python module loading.
2026-02-14 21:27:25 -06:00