https://github.com/python/cpython/commit/f38c16ade59c3a9430a46f3678cb5674390e134d
commit: f38c16ade59c3a9430a46f3678cb5674390e134d
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: StanFromIreland <[email protected]>
date: 2026-06-25T14:00:21Z
summary:

[3.14] Don't require `_testcapi` for `test_code` (GH-152185) (#152201)

(cherry picked from commit 11c241e1a8a71b5f25a304b1f428467b746f5d43)

Co-authored-by: Shahar Naveh <[email protected]>
Co-authored-by: Stan Ulbrych <[email protected]>

files:
M Lib/test/test_code.py

diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py
index 0d5c6e6e77f5d7..908e0ab3fb3a02 100644
--- a/Lib/test/test_code.py
+++ b/Lib/test/test_code.py
@@ -215,7 +215,6 @@
 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 @@ async def async_func():
         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__

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to