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
Owner

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: {**globals(), "__file__": str(init_py)} — merges __file__ into the caller's globals so both __file__ and all existing names remain available.

The previous fix (e10841a6c8e) 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: `{**globals(), "__file__": str(init_py)}` — merges `__file__` into the caller's globals so both `__file__` and all existing names remain available.
forbes added 1 commit 2026-02-15 10:21:49 +00:00
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
1762bd23d1
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.
forbes merged commit cbc09cd3c5 into main 2026-02-15 10:22:11 +00:00
forbes deleted branch fix/exec-globals-regression 2026-02-15 10:22:11 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/create#240