]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Do not use bare "except"
authorTom Tromey <tromey@adacore.com>
Tue, 19 Mar 2024 17:11:05 +0000 (11:11 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 2 Apr 2024 16:58:37 +0000 (10:58 -0600)
flake8 warns about a bare "except".  The docs point out that this will
also catch KeyboardInterrupt and SystemExit exceptions, which is
normally undesirable.  Using "except Exception" catches everything
reasonable, so this patch makes this change.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/python/lib/gdb/__init__.py
gdb/python/lib/gdb/styling.py

index 611d725af5810a1170f4ab764e89d5c81e67afe5..aae0d3680aaad2a4ffdeece62f78b0d5c1952e4d 100644 (file)
@@ -159,7 +159,7 @@ def _auto_load_packages():
                         reload(__import__(modname))
                     else:
                         __import__(modname)
-                except:
+                except Exception:
                     sys.stderr.write(traceback.format_exc() + "\n")
 
 
index 704c9926c29122d3555da093fadae2b602a96110..8e5d64f15d9a8e00de833903782cec87fc383ed2 100644 (file)
@@ -39,7 +39,7 @@ try:
             return highlight(contents, lexer, formatter).encode(
                 gdb.host_charset(), "backslashreplace"
             )
-        except:
+        except Exception:
             return None
 
     class HandleNasmComments(TokenMergeFilter):
@@ -70,7 +70,7 @@ try:
             flavor = gdb.parameter("disassembly-flavor")
             if flavor == "intel" and gdbarch.name()[:4] == "i386":
                 lexer_type = "nasm"
-        except:
+        except Exception:
             # If GDB is built without i386 support then attempting to fetch
             # the 'disassembly-flavor' parameter will throw an error, which we
             # ignore.
@@ -89,7 +89,7 @@ try:
             lexer = __get_asm_lexer(gdbarch)
             formatter = get_formatter()
             return highlight(content, lexer, formatter).rstrip().encode()
-        except:
+        except Exception:
             return content
 
 except ImportError: