public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Remove bare "except" from disassembler.py
@ 2024-04-02 17:09 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2024-04-02 17:09 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=80c69af864ce523221ec9f439997849c91c7ba85

commit 80c69af864ce523221ec9f439997849c91c7ba85
Author: Tom Tromey <tromey@adacore.com>
Date:   Tue Mar 19 10:49:20 2024 -0600

    Remove bare "except" from disassembler.py
    
    flake8 complains about a bare "except" in disassembler.py.  In this
    case, the code purports to guard against some kind of user error
    involving data structure corruption.  I think it's better here to just
    let the error occur -- py-disasm.c will show a stack trace in this
    case.
    
    Approved-By: Simon Marchi <simon.marchi@efficios.com>

Diff:
---
 gdb/python/lib/gdb/disassembler.py | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/gdb/python/lib/gdb/disassembler.py b/gdb/python/lib/gdb/disassembler.py
index ecf42688ae9..2d313ae2122 100644
--- a/gdb/python/lib/gdb/disassembler.py
+++ b/gdb/python/lib/gdb/disassembler.py
@@ -93,21 +93,14 @@ def _print_insn(info):
     disassembled."""
 
     def lookup_disassembler(arch):
-        try:
-            name = arch.name()
-            if name is None:
-                return None
-            if name in _disassemblers_dict:
-                return _disassemblers_dict[name]
-            if None in _disassemblers_dict:
-                return _disassemblers_dict[None]
-            return None
-        except:
-            # It's pretty unlikely this exception case will ever
-            # trigger, one situation would be if the user somehow
-            # corrupted the _disassemblers_dict variable such that it
-            # was no longer a dictionary.
+        name = arch.name()
+        if name is None:
             return None
+        if name in _disassemblers_dict:
+            return _disassemblers_dict[name]
+        if None in _disassemblers_dict:
+            return _disassemblers_dict[None]
+        return None
 
     disassembler = lookup_disassembler(info.architecture)
     if disassembler is None:

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-02 17:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-02 17:09 [binutils-gdb] Remove bare "except" from disassembler.py Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).