summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/cProfile.py')
-rwxr-xr-xLib/cProfile.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/cProfile.py b/Lib/cProfile.py
index 59b4699feb5..22a7d0aade8 100755
--- a/Lib/cProfile.py
+++ b/Lib/cProfile.py
@@ -175,7 +175,12 @@ def main():
'__package__': None,
'__cached__': None,
}
- runctx(code, globs, None, options.outfile, options.sort)
+ try:
+ runctx(code, globs, None, options.outfile, options.sort)
+ except BrokenPipeError as exc:
+ # Prevent "Exception ignored" during interpreter shutdown.
+ sys.stdout = None
+ sys.exit(exc.errno)
else:
parser.print_usage()
return parser