From b4ccb82ea76b98457d9dc59424632ca412511ed4 Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Wed, 15 Apr 2026 11:21:40 -0400 Subject: [Python API] Replace bare "except:" with "except Exception:" to fix signal propagation --- python/examples/encoded_strings.py | 2 +- python/examples/export_svg.py | 6 +++--- python/examples/mappedview.py | 2 +- python/examples/nds.py | 4 ++-- python/examples/nes.py | 2 +- python/examples/nsf.py | 2 +- python/examples/triage/byte.py | 2 +- python/examples/triage/view.py | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) (limited to 'python/examples') diff --git a/python/examples/encoded_strings.py b/python/examples/encoded_strings.py index 691d116c..6c12f535 100644 --- a/python/examples/encoded_strings.py +++ b/python/examples/encoded_strings.py @@ -31,7 +31,7 @@ class EncodedStringRecognizer(StringRecognizer): try: values = bytes.fromhex(type.target.attributes[name]) decoder = self.__class__.decoders[name] - except: + except Exception: return None if values is None or decoder is None: return None diff --git a/python/examples/export_svg.py b/python/examples/export_svg.py index e9ce9299..f98b970e 100755 --- a/python/examples/export_svg.py +++ b/python/examples/export_svg.py @@ -97,14 +97,14 @@ def rgbStr(tokenType): '''Given a token string name, look up the theme color for it and return as rbg(x,y,z) str''' try: color = eval(f'getThemeColor(ThemeColor.{tokenType})') - except: + except Exception: color = None if (not color): try: ctx = UIContext.activeContext() view_frame = ctx.getCurrentViewFrame() color = eval(f'getTokenColor(view_frame, InstructionTextTokenType.{tokenType})') - except: + except Exception: return 'rgb(224, 224, 224)' r = color.getRgb()[0] g = color.getRgb()[1] @@ -301,7 +301,7 @@ def render_svg(function, offset, mode, form, showOpcodes, showAddresses, orignam rgb = colors[color_str] else: rgb = [bb.highlight.red, bb.highlight.green, bb.highlight.blue] - except: + except Exception: pass output += f' \n' diff --git a/python/examples/mappedview.py b/python/examples/mappedview.py index 32963ea2..062f61da 100644 --- a/python/examples/mappedview.py +++ b/python/examples/mappedview.py @@ -143,7 +143,7 @@ class MappedView(BinaryView): # Note: This MappedView (Python) BinaryView implementation is incomplete. It ignores platform, section, and segment settings. # It's preferred that values saved in the settings system be imageBase agnostic. return True - except: + except Exception: log_error(traceback.format_exc()) return False diff --git a/python/examples/nds.py b/python/examples/nds.py index 7ca04e24..3c108c74 100644 --- a/python/examples/nds.py +++ b/python/examples/nds.py @@ -73,7 +73,7 @@ class DSView(BinaryView): ) self.add_entry_point(Architecture['armv7'].standalone_platform, self.arm_entry_addr) # type: ignore return True - except: + except Exception: log_error(traceback.format_exc()) return False @@ -90,7 +90,7 @@ class DSView(BinaryView): ) self.add_entry_point(Architecture['armv7'].standalone_platform, self.arm_entry_addr) # type: ignore return True - except: + except Exception: log_error(traceback.format_exc()) return False diff --git a/python/examples/nes.py b/python/examples/nes.py index da06bc30..ef786df4 100644 --- a/python/examples/nes.py +++ b/python/examples/nes.py @@ -691,7 +691,7 @@ class NESView(BinaryView): self.add_function(addr) return True - except: + except Exception: log_error(traceback.format_exc()) return False diff --git a/python/examples/nsf.py b/python/examples/nsf.py index 5b5f644d..2e183e1d 100644 --- a/python/examples/nsf.py +++ b/python/examples/nsf.py @@ -134,7 +134,7 @@ class NSFView(BinaryView): self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x4017, "JOY2")) return True - except: + except Exception: log_error(traceback.format_exc()) return False diff --git a/python/examples/triage/byte.py b/python/examples/triage/byte.py index 13e5d153..23e30c57 100644 --- a/python/examples/triage/byte.py +++ b/python/examples/triage/byte.py @@ -9,7 +9,7 @@ from binaryninjaui import View, ViewType, RenderContext, UIContext, UIAction from binaryninja.enums import LinearDisassemblyLineType, ThemeColor try: from binaryninja.binaryview import AddressRange -except: +except Exception: from binaryninja.function import AddressRange diff --git a/python/examples/triage/view.py b/python/examples/triage/view.py index 28a99a75..3a8b0e02 100644 --- a/python/examples/triage/view.py +++ b/python/examples/triage/view.py @@ -48,7 +48,7 @@ class TriageView(QScrollArea, View): hdr = headers.PEHeaders(self.data) elif self.data.view_type != "Raw": hdr = headers.GenericHeaders(self.data) - except: + except Exception: log.log_error(traceback.format_exc()) if hdr is not None: -- cgit v1.3.1