diff options
author | Mark Shannon <mark@hotpy.org> | 2023-05-18 09:10:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-18 09:10:15 (GMT) |
commit | cfa517d5a68bae24cbe8d9fe6b8e0d4935e507d2 (patch) | |
tree | c25c67c7ba5b46b22884fc04f62b4429443c99e5 /Lib/test | |
parent | 68b5f08b72e02f62ec787bfbb7aa99bac661daec (diff) | |
download | cpython-cfa517d5a68bae24cbe8d9fe6b8e0d4935e507d2.zip cpython-cfa517d5a68bae24cbe8d9fe6b8e0d4935e507d2.tar.gz cpython-cfa517d5a68bae24cbe8d9fe6b8e0d4935e507d2.tar.bz2 |
GH-96803: Document and test new unstable internal frame API functions (GH-104211)
Weaken contract of PyUnstable_InterpreterFrame_GetCode to return PyObject*.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_capi/test_misc.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_capi/test_misc.py b/Lib/test/test_capi/test_misc.py index 0ef0b5d..dc3441e 100644 --- a/Lib/test/test_capi/test_misc.py +++ b/Lib/test/test_capi/test_misc.py @@ -1744,6 +1744,30 @@ class Test_ModuleStateAccess(unittest.TestCase): self.assertIs(Subclass().get_defining_module(), self.module) +class TestInternalFrameApi(unittest.TestCase): + + @staticmethod + def func(): + return sys._getframe() + + def test_code(self): + frame = self.func() + code = _testinternalcapi.iframe_getcode(frame) + self.assertIs(code, self.func.__code__) + + def test_lasti(self): + frame = self.func() + lasti = _testinternalcapi.iframe_getlasti(frame) + self.assertGreater(lasti, 0) + self.assertLess(lasti, len(self.func.__code__.co_code)) + + def test_line(self): + frame = self.func() + line = _testinternalcapi.iframe_getline(frame) + firstline = self.func.__code__.co_firstlineno + self.assertEqual(line, firstline + 2) + + SUFFICIENT_TO_DEOPT_AND_SPECIALIZE = 100 class Test_Pep523API(unittest.TestCase): |