From: Simon Marchi Date: Wed, 29 Oct 2025 17:49:20 +0000 (-0400) Subject: gdb/testsuite: avoid bare except in Python files X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99f7b61f1d00a2b9f85c3defa03764f75184931b;p=thirdparty%2Fbinutils-gdb.git gdb/testsuite: avoid bare except in Python files Fix flake8 warnings like this: gdb/testsuite/gdb.python/py-unwind-inline.py:62:9: E722 do not use bare 'except' Change-Id: I9736c948bc84fefcb7db2a6ac7322cbbfe39da94 Approved-By: Tom Tromey --- diff --git a/gdb/testsuite/gdb.cp/pretty-print.py b/gdb/testsuite/gdb.cp/pretty-print.py index 6ee8d71cbe1..81ac03b713f 100644 --- a/gdb/testsuite/gdb.cp/pretty-print.py +++ b/gdb/testsuite/gdb.cp/pretty-print.py @@ -49,7 +49,7 @@ class FilteringTypePrinter(object): try: self._type_obj = gdb.lookup_type(self.name).strip_typedefs() - except: + except Exception: pass if self._type_obj is None: diff --git a/gdb/testsuite/gdb.perf/lib/perftest/measure.py b/gdb/testsuite/gdb.perf/lib/perftest/measure.py index 0e06cad84a5..efd620a1c45 100644 --- a/gdb/testsuite/gdb.perf/lib/perftest/measure.py +++ b/gdb/testsuite/gdb.perf/lib/perftest/measure.py @@ -158,7 +158,7 @@ class MeasurementVmSize(Measurement): t = open(file_path) v = t.read() t.close() - except: + except Exception: return 0 i = v.index(key) v = v[i:].split(None, 3) diff --git a/gdb/testsuite/gdb.python/py-disasm.py b/gdb/testsuite/gdb.python/py-disasm.py index 4c44de55a72..95fe9ff4117 100644 --- a/gdb/testsuite/gdb.python/py-disasm.py +++ b/gdb/testsuite/gdb.python/py-disasm.py @@ -357,7 +357,7 @@ class GlobalCachingDisassembler(TestDisassembler): raise gdb.GdbError("DisassembleInfo.address is still valid") except RuntimeError as e: assert str(e) == "DisassembleInfo is no longer valid." - except: + except Exception: raise gdb.GdbError( "DisassembleInfo.address raised an unexpected exception" ) @@ -367,7 +367,7 @@ class GlobalCachingDisassembler(TestDisassembler): raise gdb.GdbError("DisassembleInfo.architecture is still valid") except RuntimeError as e: assert str(e) == "DisassembleInfo is no longer valid." - except: + except Exception: raise gdb.GdbError( "DisassembleInfo.architecture raised an unexpected exception" ) @@ -377,7 +377,7 @@ class GlobalCachingDisassembler(TestDisassembler): raise gdb.GdbError("DisassembleInfo.read is still valid") except RuntimeError as e: assert str(e) == "DisassembleInfo is no longer valid." - except: + except Exception: raise gdb.GdbError( "DisassembleInfo.read raised an unexpected exception" ) diff --git a/gdb/testsuite/gdb.python/py-send-packet.py b/gdb/testsuite/gdb.python/py-send-packet.py index 0a0b3591711..842a305b07b 100644 --- a/gdb/testsuite/gdb.python/py-send-packet.py +++ b/gdb/testsuite/gdb.python/py-send-packet.py @@ -144,7 +144,7 @@ def run_set_global_var_test(): res = conn.send_packet("X%x,4:\xff\xff\xff\xff" % addr) except UnicodeError: saw_error = True - except: + except Exception: assert False assert saw_error diff --git a/gdb/testsuite/gdb.python/py-unwind-inline.py b/gdb/testsuite/gdb.python/py-unwind-inline.py index ca6b16e8980..1bdfd93527c 100644 --- a/gdb/testsuite/gdb.python/py-unwind-inline.py +++ b/gdb/testsuite/gdb.python/py-unwind-inline.py @@ -59,7 +59,7 @@ class dummy_unwinder(Unwinder): try: for r in self.get_regs(pending_frame): v = pending_frame.read_register(r).cast(self.void_ptr_t) - except: + except Exception: print("Dummy unwinder, exception") raise