From 40016f90aeacbcc8dadc2d3807a497a24539a805 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Thu, 4 Jun 2015 22:29:16 +0200 Subject: 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. --- kconfiglib.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'kconfiglib.py') 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 " \ -- cgit v1.2.3