From 3e012725e07941841bb4213fa9bb8b56abd01f18 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 28 Feb 2010 13:11:21 -0500 Subject: If the user's code calls sys.exit(), honor the request and exit with that status. Fixes issue #50. --- coverage/execfile.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'coverage/execfile.py') diff --git a/coverage/execfile.py b/coverage/execfile.py index 1a2ffadd..333163f8 100644 --- a/coverage/execfile.py +++ b/coverage/execfile.py @@ -51,6 +51,10 @@ def run_python_file(filename, args): # Execute the source file. try: exec_code_object(code, main_mod.__dict__) + except SystemExit: + # The user called sys.exit(). Just pass it along to the upper + # layers, where it will be handled. + raise except: # Something went wrong while executing the user code. # Get the exc_info, and pack them into an exception that we can -- cgit v1.2.1