summaryrefslogtreecommitdiff
path: root/kconfiglib.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2019-12-17 19:33:47 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2019-12-17 19:39:27 +0100
commit5adff56c0c084bff78e20ae26bcf25dd9e932d5c (patch)
treec37966111eddd2c33bd8d6f8d93bf94960a148ab /kconfiglib.py
parent24a02049484d251bbc988b177deec226d3313353 (diff)
Include sys.argv[0] in error messages when suppress_traceback=True
Handy to have the script name appear in logs.
Diffstat (limited to 'kconfiglib.py')
-rw-r--r--kconfiglib.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index 3c93938..742d231 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -934,7 +934,8 @@ class Kconfig(object):
suppress_traceback (default: False):
Helper for tools. When True, any EnvironmentError or KconfigError
generated during parsing is caught, the exception message is printed
- to stderr, and sys.exit(1) is called (which generates SystemExit).
+ to stderr together with the command name, and sys.exit(1) is called
+ (which generates SystemExit).
This hides the Python traceback for "expected" errors like syntax
errors in Kconfig files.
@@ -946,10 +947,13 @@ class Kconfig(object):
self._init(filename, warn, warn_to_stderr, encoding)
except (EnvironmentError, KconfigError) as e:
if suppress_traceback:
+ cmd = sys.argv[0] # Empty string if missisng
+ if cmd:
+ cmd += ": "
# Some long exception messages have extra newlines for better
# formatting when reported as an unhandled exception. Strip
# them here.
- sys.exit(str(e).strip())
+ sys.exit(cmd + str(e).strip())
raise
def _init(self, filename, warn, warn_to_stderr, encoding):