mirror of
https://github.com/python/cpython
synced 2024-09-16 03:20:00 +00:00
bpo-42005: profile and cProfile catch BrokenPipeError (GH-22643)
This commit is contained in:
parent
f1ff800db1
commit
3554fa4abe
|
@ -175,7 +175,12 @@ def main():
|
||||||
'__package__': None,
|
'__package__': None,
|
||||||
'__cached__': 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:
|
else:
|
||||||
parser.print_usage()
|
parser.print_usage()
|
||||||
return parser
|
return parser
|
||||||
|
|
|
@ -595,7 +595,12 @@ def main():
|
||||||
'__package__': None,
|
'__package__': None,
|
||||||
'__cached__': 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:
|
else:
|
||||||
parser.print_usage()
|
parser.print_usage()
|
||||||
return parser
|
return parser
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix CLI of :mod:`cProfile` and :mod:`profile` to catch
|
||||||
|
:exc:`BrokenPipeError`.
|
Loading…
Reference in a new issue