fix: preserve caller globals in exec() for module Init.py/InitGui.py loading #240

Merged
forbes merged 1 commits from fix/exec-globals-regression into main 2026-02-15 10:22:11 +00:00

1 Commits

Author SHA1 Message Date
forbes
1762bd23d1 fix: preserve caller globals in exec() for module Init.py/InitGui.py loading
Some checks failed
Build and Test / build (pull_request) Has been cancelled
The previous fix (e10841a6c8) passed {"__file__": ...} as the globals
argument to exec(), which replaced the caller's globals dict entirely.
This stripped FreeCAD, FreeCADGui, Workbench, and other names that
modules expect to be available, causing NameError failures across
Material, Tux, Mesh, ReverseEngineering, OpenSCAD, Inspection, Robot,
AddonManager, MeshPart, and others.

Fix by merging __file__ into the caller's globals with
{**globals(), "__file__": str(init_py)} so both __file__ and all
existing names remain available in the executed code.
2026-02-15 04:21:26 -06:00