diff mbox series

[wic,7/9] plugins/source/bootimg_biosplusefi.py: add import os

Message ID 20260403183644.2783267-8-twoerner@gmail.com
State New
Headers show
Series standalone wic repository | expand

Commit Message

Trevor Woerner April 3, 2026, 6:36 p.m. UTC
BitBake's bb/build.py:55 deliberately injects os (and bb) into Python's
__builtins__ at the module level:

    # When we execute a Python function, we'd like certain things
    # in all namespaces, hence we add them to __builtins__.
    # If we do not do this and use the exec globals, they will
    # not be available to subfunctions.
    if hasattr(__builtins__, '__setitem__'):
        builtins = __builtins__
    else:
        builtins = __builtins__.__dict__

    builtins['bb'] = bb
    builtins['os'] = os

When wic was part of oe-core this injection would occur, and once
os is in __builtins__, Python's name resolution (locals -> globals
-> builtins) finds it for any code in the process, even modules
that never explicitly import os. So when bootimg_biosplusefi.py's
__instanciateSubClasses referenced os.path.join(...), Python resolved os
from builtins rather than the module's own globals.

Since wic is now split out from oe-core (and bitbake) this plugin fails
with:
	NameError: name 'os' is not defined.

Therefore, add "import os" to bootimg_biosplusefi.py.

NOTE: this commit does not work as-is, but is being provided in order to
      explicitly show a clean transition from oe-core

AI-Generated: codex/claude-opus-4-6 (xhigh)
Reviewed-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Reviewed-by: Mark Hatle <mark.hatle@kernel.crashing.org>
Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
 src/wic/plugins/source/bootimg_biosplusefi.py | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/src/wic/plugins/source/bootimg_biosplusefi.py b/src/wic/plugins/source/bootimg_biosplusefi.py
index 4279ddded83a..cd7cd270a970 100644
--- a/src/wic/plugins/source/bootimg_biosplusefi.py
+++ b/src/wic/plugins/source/bootimg_biosplusefi.py
@@ -19,6 +19,7 @@ 
 # William Bourque <wbourque [at) gmail.com>
 
 import types
+import os
 
 from wic.pluginbase import SourcePlugin
 from importlib.machinery import SourceFileLoader