From e5445b9749a6276250ee3b7a49551500f8ef5313 Mon Sep 17 00:00:00 2001 From: Kotesh Kumar Yelamati Date: Mon, 13 Jul 2026 08:34:17 -0400 Subject: [PATCH 1/2] Fix bare except in memory_profiler.py: use except (ValueError, IndexError) --- memory_profiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memory_profiler.py b/memory_profiler.py index f0b52cd..c7cbfe7 100644 --- a/memory_profiler.py +++ b/memory_profiler.py @@ -201,7 +201,7 @@ def posix_tool(): return mem, time.time() else: return mem - except: + except (ValueError, IndexError): if timestamps: return -1, time.time() else: From 03b9281d4302a1ef298ef8ca3253574004b8435b Mon Sep 17 00:00:00 2001 From: Kotesh Kumar Yelamati Date: Mon, 13 Jul 2026 08:35:12 -0400 Subject: [PATCH 2/2] Fix bare excepts in mprof.py: use specific exception types --- mprof.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mprof.py b/mprof.py index 7753d7e..f67a755 100644 --- a/mprof.py +++ b/mprof.py @@ -248,7 +248,7 @@ def run_action(): p = proc.pid try: cmd_line = proc.cmdline() - except: + except Exception: cmd_line = get_cmd_line(program) if args.timeout is None: args.timeout = 3600 @@ -756,7 +756,7 @@ def plot_action(): def xlim_type(value): try: newvalue = [float(x) for x in value.split(',')] - except: + except (ValueError, AttributeError): raise ArgumentError("'%s' option must contain two numbers separated with a comma" % value) if len(newvalue) != 2: raise ArgumentError("'%s' option must contain two numbers separated with a comma" % value)