diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2015-06-04 22:29:16 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2015-06-04 22:45:13 +0200 |
| commit | 40016f90aeacbcc8dadc2d3807a497a24539a805 (patch) | |
| tree | 91f3352de327c9568df25240b6e3eb39e470de65 | |
| parent | 98afe55dda39653bb56c29724deceb5436831ace (diff) | |
Clean up parse error handling.
strip() the faulty line (seeing that whitespace probably isn't helpful),
remove an assert that probably isn't useful in practice, and simplify
the code.
| -rw-r--r-- | kconfiglib.py | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 5439a8f..f828369 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -3750,19 +3750,10 @@ def _tokenization_error(s, filename, linenr): .format(loc, s.strip()) def _parse_error(s, msg, filename, linenr): - error_str = "" - - if filename is not None: - assert linenr is not None - error_str += "{0}:{1}: ".format(filename, linenr) - - if s.endswith("\n"): - s = s[:-1] - - error_str += 'Error while parsing "{0}"'.format(s) + \ - ("." if msg is None else ": " + msg) - - raise Kconfig_Syntax_Error, error_str + loc = "" if filename is None else "{0}:{1}: ".format(filename, linenr) + raise Kconfig_Syntax_Error, "{0}Couldn't parse '{1}'{2}" \ + .format(loc, s.strip(), + "." if msg is None else ": " + msg) def _internal_error(msg): msg += "\nSorry! You may want to send an email to ulfalizer a.t Google's " \ |
