From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 25 Jun 2026 14:00:21 +0000 (+0200) Subject: [3.14] Don't require `_testcapi` for `test_code` (GH-152185) (#152201) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f38c16ade59c3a9430a46f3678cb5674390e134d;p=thirdparty%2FPython%2Fcpython.git [3.14] Don't require `_testcapi` for `test_code` (GH-152185) (#152201) (cherry picked from commit 11c241e1a8a71b5f25a304b1f428467b746f5d43) Co-authored-by: Shahar Naveh <50263213+ShaharNaveh@users.noreply.github.com> Co-authored-by: Stan Ulbrych --- diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py index 0d5c6e6e77f5..908e0ab3fb3a 100644 --- a/Lib/test/test_code.py +++ b/Lib/test/test_code.py @@ -215,7 +215,6 @@ 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: import _testinternalcapi except ModuleNotFoundError: @@ -1485,6 +1484,8 @@ class CodeLocationTest(unittest.TestCase): rc, out, err = assert_python_ok('-OO', '-c', code) def test_co_branches(self): + _testcapi = import_helper.import_module("_testcapi") + code_offset_to_line = _testcapi.code_offset_to_line def get_line_branches(func): code = func.__code__