From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 7 Apr 2026 14:51:43 +0000 (+0200) Subject: [3.13] gh-124613: Deactivate perf support in tests if the jit is set (GH-124794)... X-Git-Tag: v3.13.13~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9f15d25c523e76db7461e4954c762a02ea5707fb;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-124613: Deactivate perf support in tests if the jit is set (GH-124794) (GH-148214) gh-124613: Deactivate perf support in tests if the jit is set (GH-124794) gh-124613: Deactivate the JIT during perf tests (cherry picked from commit 5e9e50612eb27aef8f74a0ccc234e5cfae50c4d7) Signed-off-by: Pablo Galindo Co-authored-by: Pablo Galindo Salgado --- diff --git a/Lib/test/test_perf_profiler.py b/Lib/test/test_perf_profiler.py index ee417371a5d1..cc32628c25bf 100644 --- a/Lib/test/test_perf_profiler.py +++ b/Lib/test/test_perf_profiler.py @@ -63,11 +63,13 @@ class TestPerfTrampoline(unittest.TestCase): """ with temp_dir() as script_dir: script = make_script(script_dir, "perftest", code) + env = {**os.environ, "PYTHON_JIT": "0"} with subprocess.Popen( [sys.executable, "-Xperf", script], text=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE, + env=env, ) as process: stdout, stderr = process.communicate() @@ -131,11 +133,13 @@ class TestPerfTrampoline(unittest.TestCase): """ with temp_dir() as script_dir: script = make_script(script_dir, "perftest", code) + env = {**os.environ, "PYTHON_JIT": "0"} with subprocess.Popen( [sys.executable, "-Xperf", script], text=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE, + env=env, ) as process: stdout, stderr = process.communicate() @@ -232,11 +236,13 @@ class TestPerfTrampoline(unittest.TestCase): """ with temp_dir() as script_dir: script = make_script(script_dir, "perftest", code) + env = {**os.environ, "PYTHON_JIT": "0"} with subprocess.Popen( [sys.executable, script], text=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE, + env=env, ) as process: stdout, stderr = process.communicate() @@ -333,8 +339,9 @@ def perf_command_works(): "-c", 'print("hello")', ) + env = {**os.environ, "PYTHON_JIT": "0"} stdout = subprocess.check_output( - cmd, cwd=script_dir, text=True, stderr=subprocess.STDOUT + cmd, cwd=script_dir, text=True, stderr=subprocess.STDOUT, env=env ) except (subprocess.SubprocessError, OSError): return False @@ -346,11 +353,10 @@ def perf_command_works(): def run_perf(cwd, *args, use_jit=False, **env_vars): + env = os.environ.copy() if env_vars: - env = os.environ.copy() env.update(env_vars) - else: - env = None + env["PYTHON_JIT"] = "0" output_file = cwd + "/perf_output.perf" if not use_jit: base_cmd = ( @@ -529,11 +535,13 @@ class TestPerfProfiler(unittest.TestCase, TestPerfProfilerMixin): with temp_dir() as script_dir: script = make_script(script_dir, "perftest", code) + env = {**os.environ, "PYTHON_JIT": "0"} with subprocess.Popen( [sys.executable, "-Xperf", script], universal_newlines=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE, + env=env, ) as process: stdout, stderr = process.communicate()