diff options
author | Matthew Krafczyk <krafczyk.matthew@gmail.com> | 2016-11-17 12:47:15 -0500 |
---|---|---|
committer | Matthew Krafczyk <krafczyk.matthew@gmail.com> | 2016-11-17 12:51:41 -0500 |
commit | f1b26cb72e643cebc0cf3a650c1a4189628ed7df (patch) | |
tree | e9d0982c1b1c8f0bbda9cda5badeaaef17e0ec40 | |
parent | de7171db8a14660e7789349b1ed9c68f27692f48 (diff) | |
download | spack-f1b26cb72e643cebc0cf3a650c1a4189628ed7df.tar.gz spack-f1b26cb72e643cebc0cf3a650c1a4189628ed7df.tar.bz2 spack-f1b26cb72e643cebc0cf3a650c1a4189628ed7df.tar.xz spack-f1b26cb72e643cebc0cf3a650c1a4189628ed7df.zip |
Improve stacktrace printing
Sometimes files in the stacktrace are not from spack. Remove these
files before finding the spack root.
-rw-r--r-- | lib/spack/llnl/util/tty/__init__.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/spack/llnl/util/tty/__init__.py b/lib/spack/llnl/util/tty/__init__.py index 3743137daa..1381bb2f7d 100644 --- a/lib/spack/llnl/util/tty/__init__.py +++ b/lib/spack/llnl/util/tty/__init__.py @@ -69,11 +69,13 @@ def set_stacktrace(flag): def process_stacktrace(countback): """Gives file and line frame 'countback' frames from the bottom""" st = traceback.extract_stack() - # All entries will be spack files based on how this function is called. - # We use commonprefix to find what the spack 'root' directory is. + # Not all entries may be spack files, we have to remove those that aren't. file_list = [] for frame in st: - file_list.append(frame[0]) + # Check that the file is a spack file + if frame[0].find("/spack") >= 0: + file_list.append(frame[0]) + # We use commonprefix to find what the spack 'root' directory is. root_dir = os.path.commonprefix(file_list) root_len = len(root_dir) st_idx = len(st) - countback - 1 |