From 639ca60a464a0e0454c5d291ee71b9b3d8de7d8f Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sat, 15 Dec 2018 21:43:19 +0100 Subject: Simplify _decoding_error() a bit Also add quotes around the filename. --- kconfiglib.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kconfiglib.py b/kconfiglib.py index f3c51b1..30b7507 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -5903,18 +5903,15 @@ def _decoding_error(e, filename, macro_linenr=None): # macro_linenr holds the line number where it was run (the exact line # number isn't available for decoding errors in files). - if macro_linenr is None: - loc = filename - else: - loc = "output from macro at {}:{}".format(filename, macro_linenr) - raise KconfigError( "\n" "Malformed {} in {}\n" "Context: {}\n" "Problematic data: {}\n" "Reason: {}".format( - e.encoding, loc, + e.encoding, + "'{}'".format(filename) if macro_linenr is None else + "output from macro at {}:{}".format(filename, macro_linenr), e.object[max(e.start - 40, 0):e.end + 40], e.object[e.start:e.end], e.reason)) -- cgit v1.2.3