It is not possible to validate an ELF file without pyelftools, make the
error more clear and informative to the user:

> binman: Python: No module named 'elftools'

rather than:

> binman: name 'ELFError' is not defined

Signed-off-by: Dmitrii Sharshakov <[email protected]>
---
Make the error more informative and indicative of environment issue and
not a code one
---
 tools/binman/elf.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/binman/elf.py b/tools/binman/elf.py
index 6ac960e0419..899c84ad36d 100644
--- a/tools/binman/elf.py
+++ b/tools/binman/elf.py
@@ -570,6 +570,8 @@ def is_valid(data):
     Returns:
         bool: True if a valid Elf file, False if not
     """
+    if not ELF_TOOLS:
+        raise ValueError("Python: No module named 'elftools'")
     try:
         DecodeElf(data, 0)
         return True

---
base-commit: 1bcb2fe324180d0a8cfbdb0511737eba1d5b8550
change-id: 20260109-pyelftools-warning-6df5f57ca5b8

Best regards,
-- 
Dmitrii Sharshakov <[email protected]>

Reply via email to