mirror of
https://github.com/python/cpython.git
synced 2026-06-28 03:41:13 +00:00
[3.15] gh-152434: Block --async-aware with --binary (GH-152444) (#152446)
gh-152434: Block --async-aware with --binary (GH-152444)
The binary writer does not currently handle AwaitedInfo samples and
crashes when running in --async-aware mode.
(cherry picked from commit 876c06cab9)
Co-authored-by: László Kiss Kollár <kiss.kollar.laszlo@gmail.com>
This commit is contained in:
parent
e88d41685b
commit
61bb57fa3f
2 changed files with 20 additions and 1 deletions
|
|
@ -875,13 +875,15 @@ def _validate_args(args, parser):
|
|||
if hasattr(args, 'live') and args.live:
|
||||
parser.error("--subprocesses is incompatible with --live mode.")
|
||||
|
||||
# Async-aware mode is incompatible with --native, --no-gc, --mode, and --all-threads
|
||||
# Async-aware mode is incompatible with options that need thread data.
|
||||
if getattr(args, 'async_aware', False):
|
||||
issues = []
|
||||
if getattr(args, 'native', False):
|
||||
issues.append("--native")
|
||||
if not getattr(args, 'gc', True):
|
||||
issues.append("--no-gc")
|
||||
if getattr(args, 'format', None) == "binary":
|
||||
issues.append("--binary")
|
||||
if hasattr(args, 'mode') and args.mode != "wall":
|
||||
issues.append(f"--mode={args.mode}")
|
||||
if hasattr(args, 'all_threads') and args.all_threads:
|
||||
|
|
|
|||
|
|
@ -866,6 +866,23 @@ def test_async_aware_incompatible_with_all_threads(self):
|
|||
self.assertIn("--all-threads", error_msg)
|
||||
self.assertIn("incompatible with --async-aware", error_msg)
|
||||
|
||||
def test_async_aware_incompatible_with_binary(self):
|
||||
"""Test --async-aware is incompatible with --binary."""
|
||||
test_args = ["profiling.sampling.cli", "attach", "12345",
|
||||
"--async-aware", "--binary"]
|
||||
|
||||
with (
|
||||
mock.patch("sys.argv", test_args),
|
||||
mock.patch("sys.stderr", io.StringIO()) as mock_stderr,
|
||||
self.assertRaises(SystemExit) as cm,
|
||||
):
|
||||
main()
|
||||
|
||||
self.assertEqual(cm.exception.code, 2) # argparse error
|
||||
error_msg = mock_stderr.getvalue()
|
||||
self.assertIn("--binary", error_msg)
|
||||
self.assertIn("incompatible with --async-aware", error_msg)
|
||||
|
||||
@unittest.skipIf(is_emscripten, "subprocess not available")
|
||||
def test_run_nonexistent_script_exits_cleanly(self):
|
||||
"""Test that running a non-existent script exits with a clean error."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue