From 15c635b873105eda2861430d062ea3f6bdfe9d9b Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Fri, 1 Aug 2025 17:02:14 -0400 Subject: Use log_error_for_exception in the Python API to pass tracebacks in the stack trace associated with log messages, instead of creating large mutli-line messages for every exception --- python/platform.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'python/platform.py') diff --git a/python/platform.py b/python/platform.py index 29eb81b0..98f3109a 100644 --- a/python/platform.py +++ b/python/platform.py @@ -34,7 +34,7 @@ from . import typelibrary from . import architecture from . import typecontainer from . import binaryview -from .log import log_error +from .log import log_error_for_exception class _PlatformMetaClass(type): @@ -160,7 +160,7 @@ class Platform(metaclass=_PlatformMetaClass): view_obj = binaryview.BinaryView(handle=core.BNNewViewReference(view)) self.view_init(view) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Platform._view_init") def _get_global_regs(self, ctxt, count): try: @@ -173,7 +173,7 @@ class Platform(metaclass=_PlatformMetaClass): self._pending_reg_lists[result.value] = (result, reg_buf) return result.value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Platform._get_global_regs") count[0] = 0 return None @@ -184,7 +184,7 @@ class Platform(metaclass=_PlatformMetaClass): raise ValueError("freeing register list that wasn't allocated") del self._pending_reg_lists[buf.value] except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Platform._free_register_list") def _get_global_reg_type(self, ctxt, reg): try: @@ -195,7 +195,7 @@ class Platform(metaclass=_PlatformMetaClass): return ctypes.cast(handle, ctypes.c_void_p).value return None except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Platform._get_global_reg_type") return None def _get_address_size(self, ctxt): @@ -289,7 +289,7 @@ class Platform(metaclass=_PlatformMetaClass): raise ValueError("freeing source_file_values list that wasn't allocated") del self._pending_parser_input_lists[buf.value] except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Platform._free_type_parser_input") def adjust_type_parser_input( self, -- cgit v1.3.1