From bec5bce4fd46b78b1b661ed991bcd4fc5adb9b48 Mon Sep 17 00:00:00 2001 From: Matt Page Date: Fri, 18 Oct 2024 09:57:05 -0700 Subject: [PATCH] Add command-line tests for enabling TLBC --- Lib/test/test_cmd_line.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index f088e5b8b5089c..64bf310d569c14 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -1084,6 +1084,23 @@ def test(x, y): assert_python_ok("-W", "always", "-X", "tlbc=0", "-c", code) assert_python_ok("-W", "always", "-c", code, PYTHON_TLBC="0") + @unittest.skipUnless(support.Py_GIL_DISABLED, + "PYTHON_TLBC and -X tlbc" + " only supported in Py_GIL_DISABLED builds") + @threading_helper.requires_working_threading() + def test_enable_thread_local_bytecode(self): + code = """if 1: + import threading + def test(x, y): + return x + y + t = threading.Thread(target=test, args=(1,2)) + t.start() + t.join()""" + # The functionality of thread-local bytecode is tested more extensively + # in test_thread_local_bytecode + assert_python_ok("-W", "always", "-X", "tlbc=1", "-c", code) + assert_python_ok("-W", "always", "-c", code, PYTHON_TLBC="1") + @unittest.skipUnless(support.Py_GIL_DISABLED, "PYTHON_TLBC and -X tlbc" " only supported in Py_GIL_DISABLED builds")