diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-01-20 01:19:08 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-20 01:19:08 -0800 |
commit | 0654c4c4cc54a325e878154f8b117159d0105cf7 (patch) | |
tree | fdb990905a2fa6b30b4e5732757a5cf9487aa2e6 /Lib/cProfile.py | |
parent | 50938b63fbb0d4bed24dceccf188b8d0fe58463c (diff) | |
download | cpython-git-0654c4c4cc54a325e878154f8b117159d0105cf7.tar.gz |
bpo-42005: profile and cProfile catch BrokenPipeError (GH-22643)
(cherry picked from commit 3554fa4abecfb77ac5fcaa5ce8310eeca5683960)
Co-authored-by: Zhiming Wang <i@zhimingwang.org>
Diffstat (limited to 'Lib/cProfile.py')
-rwxr-xr-x | Lib/cProfile.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/cProfile.py b/Lib/cProfile.py index 59b4699feb..22a7d0aade 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 |