From cb15b6a49fcc44f681e38e21971466e6d1bf1c8c Mon Sep 17 00:00:00 2001 From: Petru Conduraru Date: Mon, 20 Jul 2026 09:27:22 +0300 Subject: [PATCH] Preserve the real cause when the ifcopenshell wrapper fails to load (#8785) * Keep real cause in wrapper ImportError When the compiled wrapper exists for the current interpreter but fails to load (for example a glibc version mismatch, as on AWS Lambda in issue 5927), the bare except rewrote the error into the misleading "IfcOpenShell not built for ''" message. Environments such as AWS Lambda or the Blender add-on dialog only surface the final exception message, so the actual cause was invisible and undiagnosable. Keep the "not built for" message only when no matching binary is present, and otherwise include the original loader error, chaining the cause in both branches. This change was AI-generated. Fixes #5927 * Simplify wrapper import failure to a single message Per review feedback, drop the filesystem scan and the two message variants. Always raise the classic "IfcOpenShell not built for ''" message with the original exception appended in parentheses, still chained as the cause. Environments that only show the final exception message (AWS Lambda, the Blender add-on dialog) now surface the real loader error, such as the glibc version mismatch in issue 5927, without any extra logic. This change was AI-generated. (cherry picked from commit 04a2535a9838479720354c8c08e5913582dc5987) --- src/ifcopenshell-python/ifcopenshell/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/__init__.py b/src/ifcopenshell-python/ifcopenshell/__init__.py index 115914a40b..b059dfb7e0 100644 --- a/src/ifcopenshell-python/ifcopenshell/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/__init__.py @@ -85,8 +85,8 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "lib", p try: from . import ifcopenshell_wrapper -except Exception: - raise ImportError("IfcOpenShell not built for '%s'" % python_distribution) +except Exception as e: + raise ImportError("IfcOpenShell not built for '%s' (%s)" % (python_distribution, e)) from e from . import guid from .ifcopenshell_wrapper import entity_instance, file