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: 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)