bugfix: always generate a stack trace when spack is run with --debug (#11940)
- We weren't previously printing stack traces on SystemExit or KeyboardInterrupts. - Either raise or print the stacktrace in these cases.
This commit is contained in:
		@@ -16,6 +16,7 @@
 | 
				
			|||||||
import inspect
 | 
					import inspect
 | 
				
			||||||
import pstats
 | 
					import pstats
 | 
				
			||||||
import argparse
 | 
					import argparse
 | 
				
			||||||
 | 
					import traceback
 | 
				
			||||||
from six import StringIO
 | 
					from six import StringIO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import llnl.util.tty as tty
 | 
					import llnl.util.tty as tty
 | 
				
			||||||
@@ -705,10 +706,14 @@ def main(argv=None):
 | 
				
			|||||||
        tty.die(e)
 | 
					        tty.die(e)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    except KeyboardInterrupt:
 | 
					    except KeyboardInterrupt:
 | 
				
			||||||
 | 
					        if spack.config.get('config:debug'):
 | 
				
			||||||
 | 
					            raise
 | 
				
			||||||
        sys.stderr.write('\n')
 | 
					        sys.stderr.write('\n')
 | 
				
			||||||
        tty.die("Keyboard interrupt.")
 | 
					        tty.die("Keyboard interrupt.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    except SystemExit as e:
 | 
					    except SystemExit as e:
 | 
				
			||||||
 | 
					        if spack.config.get('config:debug'):
 | 
				
			||||||
 | 
					            traceback.print_exc()
 | 
				
			||||||
        return e.code
 | 
					        return e.code
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user