From 1118f6f4f2900d7424521a97465b4f7b92a650f6 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Thu, 8 Jan 2026 16:00:03 +0800 Subject: [PATCH 1/2] Add Emscripten test skips for recently added tests. --- Lib/profiling/sampling/sample.py | 2 +- Lib/test/test_grammar.py | 9 +++++++-- .../test_profiling/test_sampling_profiler/test_cli.py | 1 + .../test_sampling_profiler/test_collectors.py | 3 +++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Lib/profiling/sampling/sample.py b/Lib/profiling/sampling/sample.py index e73306ebf290e7..530a0fe85b20b5 100644 --- a/Lib/profiling/sampling/sample.py +++ b/Lib/profiling/sampling/sample.py @@ -41,7 +41,7 @@ def _pause_threads(unwinder, blocking): except ImportError: LiveStatsCollector = None -_FREE_THREADED_BUILD = sysconfig.get_config_var("Py_GIL_DISABLED") is not None +_FREE_THREADED_BUILD = bool(sysconfig.get_config_var("Py_GIL_DISABLED")) # Minimum number of samples required before showing the TUI # If fewer samples are collected, we skip the TUI and just print a message MIN_SAMPLES_FOR_TUI = 200 diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index cfb24a5c457820..ebcd98a0a37776 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -1,8 +1,6 @@ # Python test set -- part 1, grammar. # This just tests whether the parser accepts them all. -from test.support import check_syntax_error, skip_wasi_stack_overflow -from test.support import import_helper import annotationlib import inspect import unittest @@ -18,6 +16,12 @@ import typing from test.typinganndata import ann_module2 import test +from test.support import ( + check_syntax_error, + import_helper, + skip_emscripten_stack_overflow, + skip_wasi_stack_overflow, +) from test.support.numbers import ( VALID_UNDERSCORE_LITERALS, INVALID_UNDERSCORE_LITERALS, @@ -250,6 +254,7 @@ def test_eof_error(self): self.assertIn("was never closed", str(cm.exception)) @skip_wasi_stack_overflow() + @skip_emscripten_stack_overflow() def test_max_level(self): # Macro defined in Parser/lexer/state.h MAXLEVEL = 200 diff --git a/Lib/test/test_profiling/test_sampling_profiler/test_cli.py b/Lib/test/test_profiling/test_sampling_profiler/test_cli.py index f187f6c51d88e2..0d92bd1796e9af 100644 --- a/Lib/test/test_profiling/test_sampling_profiler/test_cli.py +++ b/Lib/test/test_profiling/test_sampling_profiler/test_cli.py @@ -714,6 +714,7 @@ def test_run_nonexistent_module_exits_cleanly(self): with self.assertRaisesRegex(SamplingModuleNotFoundError, "Module '[\\w/.]+' not found."): main() + @unittest.skipIf(is_emscripten, "subprocess not available") def test_cli_attach_nonexistent_pid(self): fake_pid = "99999" with mock.patch("sys.argv", ["profiling.sampling.cli", "attach", fake_pid]): diff --git a/Lib/test/test_profiling/test_sampling_profiler/test_collectors.py b/Lib/test/test_profiling/test_sampling_profiler/test_collectors.py index ae336ccdb941ce..8e6afa91e89daf 100644 --- a/Lib/test/test_profiling/test_sampling_profiler/test_collectors.py +++ b/Lib/test/test_profiling/test_sampling_profiler/test_collectors.py @@ -7,6 +7,8 @@ import tempfile import unittest +from test.support import is_emscripten + try: import _remote_debugging # noqa: F401 from profiling.sampling.pstats_collector import PstatsCollector @@ -599,6 +601,7 @@ def test_gecko_collector_basic(self): self.assertGreater(stack_table["length"], 0) self.assertGreater(len(stack_table["frame"]), 0) + @unittest.skipIf(is_emscripten, "threads not available") def test_gecko_collector_export(self): """Test Gecko profile export functionality.""" gecko_out = tempfile.NamedTemporaryFile(suffix=".json", delete=False) From 9c4d800f1e26bc434521fab9e8c270f903ac8cd7 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Thu, 8 Jan 2026 16:44:13 +0800 Subject: [PATCH 2/2] Revert sysconfig freethreading check. --- Lib/profiling/sampling/sample.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/profiling/sampling/sample.py b/Lib/profiling/sampling/sample.py index 530a0fe85b20b5..e73306ebf290e7 100644 --- a/Lib/profiling/sampling/sample.py +++ b/Lib/profiling/sampling/sample.py @@ -41,7 +41,7 @@ def _pause_threads(unwinder, blocking): except ImportError: LiveStatsCollector = None -_FREE_THREADED_BUILD = bool(sysconfig.get_config_var("Py_GIL_DISABLED")) +_FREE_THREADED_BUILD = sysconfig.get_config_var("Py_GIL_DISABLED") is not None # Minimum number of samples required before showing the TUI # If fewer samples are collected, we skip the TUI and just print a message MIN_SAMPLES_FOR_TUI = 200