diff options
author | Zhiming Wang <i@zhimingwang.org> | 2021-01-20 08:56:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-20 08:56:21 (GMT) |
commit | 3554fa4abecfb77ac5fcaa5ce8310eeca5683960 (patch) | |
tree | 152dc55103cd8c62b737be5d63b4615aba1431cc /Lib/profile.py | |
parent | f1ff800db1f9fa5ff8f2fa2863796a46bfa9ee46 (diff) | |
download | cpython-3554fa4abecfb77ac5fcaa5ce8310eeca5683960.zip cpython-3554fa4abecfb77ac5fcaa5ce8310eeca5683960.tar.gz cpython-3554fa4abecfb77ac5fcaa5ce8310eeca5683960.tar.bz2 |
bpo-42005: profile and cProfile catch BrokenPipeError (GH-22643)
Diffstat (limited to 'Lib/profile.py')
-rwxr-xr-x | Lib/profile.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/profile.py b/Lib/profile.py index 5cb017ed..d8599fb 100755 --- a/Lib/profile.py +++ b/Lib/profile.py @@ -595,7 +595,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 |