From 780b9b61dec3e142e46c9a82146d2af4e1144123 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Fri, 10 Jul 2020 08:30:31 -0700 Subject: [PATCH] specify IndexError exception in try/except block --- jc/parsers/sysctl.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jc/parsers/sysctl.py b/jc/parsers/sysctl.py index eb236c0e..f89b0508 100644 --- a/jc/parsers/sysctl.py +++ b/jc/parsers/sysctl.py @@ -141,9 +141,9 @@ def parse(data, raw=False, quiet=False): raw_output[key] = value continue - # if there is an exception, then there was no delimiter in the line. In this case - # just append the data line as a value to the previous key. - except Exception: + # if there is an IndexError exception, then there was no delimiter in the line. + # In this case just append the data line as a value to the previous key. + except IndexError: prior_key = [*raw_output.keys()][-1] raw_output[prior_key] = raw_output[prior_key] + '\n' + line continue