From 47c2acd40e7107a1716655a2c8d9c9435231e27a Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Mon, 16 Mar 2026 10:18:03 +0900 Subject: [PATCH] Fix code_offset_to_line handling --- Lib/test/test_code.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py index 031763626..8b4457ca2 100644 --- a/Lib/test/test_code.py +++ b/Lib/test/test_code.py @@ -215,7 +215,10 @@ from test.support.script_helper import assert_python_ok from test.support import threading_helper, import_helper from test.support.bytecode_helper import instructions_with_positions from opcode import opmap, opname -from _testcapi import code_offset_to_line +try: + from _testcapi import code_offset_to_line +except ModuleNotFoundError: + code_offset_to_line = None try: import _testinternalcapi except ModuleNotFoundError: @@ -1490,6 +1493,7 @@ class CodeLocationTest(unittest.TestCase): rc, out, err = assert_python_ok('-OO', '-c', code) + @unittest.skipUnless(code_offset_to_line, '_testcapi required') def test_co_branches(self): def get_line_branches(func):