From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Fri, 5 Dec 2025 19:36:28 +0000 (+0000) Subject: gh-142318: Fix typing `'q'` at interactive help screen exiting Tachyon (#142319) X-Git-Tag: v3.15.0a3~193 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcac498e501db3983ce22851c88f88561ae46351;p=thirdparty%2FPython%2Fcpython.git gh-142318: Fix typing `'q'` at interactive help screen exiting Tachyon (#142319) --- diff --git a/Lib/profiling/sampling/live_collector/collector.py b/Lib/profiling/sampling/live_collector/collector.py index 4b69275a2f07..7adbf1bbe7f6 100644 --- a/Lib/profiling/sampling/live_collector/collector.py +++ b/Lib/profiling/sampling/live_collector/collector.py @@ -861,10 +861,12 @@ class LiveStatsCollector(Collector): # Handle help toggle keys if ch == ord("h") or ch == ord("H") or ch == ord("?"): self.show_help = not self.show_help + return # If showing help, any other key closes it - elif self.show_help and ch != -1: + if self.show_help and ch != -1: self.show_help = False + return # Handle regular commands if ch == ord("q") or ch == ord("Q"): diff --git a/Lib/test/test_profiling/test_sampling_profiler/test_live_collector_interaction.py b/Lib/test/test_profiling/test_sampling_profiler/test_live_collector_interaction.py index 388f462cf21b..a58703665528 100644 --- a/Lib/test/test_profiling/test_sampling_profiler/test_live_collector_interaction.py +++ b/Lib/test/test_profiling/test_sampling_profiler/test_live_collector_interaction.py @@ -173,6 +173,19 @@ class TestLiveCollectorInteractiveControls(unittest.TestCase): self.assertTrue(self.collector.show_help) + def test_help_dismiss_with_q_does_not_quit(self): + """Test that pressing 'q' while help is shown only closes help, not quit""" + self.assertFalse(self.collector.show_help) + self.display.simulate_input(ord("h")) + self.collector._handle_input() + self.assertTrue(self.collector.show_help) + + self.display.simulate_input(ord("q")) + self.collector._handle_input() + + self.assertFalse(self.collector.show_help) + self.assertTrue(self.collector.running) + def test_filter_clear(self): """Test clearing filter.""" self.collector.filter_pattern = "test" diff --git a/Misc/NEWS.d/next/Library/2025-12-05-18-25-29.gh-issue-142318.EzcQ3N.rst b/Misc/NEWS.d/next/Library/2025-12-05-18-25-29.gh-issue-142318.EzcQ3N.rst new file mode 100644 index 000000000000..8710ebfb1a1a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-12-05-18-25-29.gh-issue-142318.EzcQ3N.rst @@ -0,0 +1,2 @@ +Fix typing ``'q'`` at the help of the interactive tachyon profiler exiting +the profiler.