mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-91248: Add PyFrame_GetVar() function (#95712)
Add PyFrame_GetVar() and PyFrame_GetVarString() functions to get a frame variable by its name. Move PyFrameObject C API tests from test_capi to test_frame.
This commit is contained in:
parent
acf4d5d5bd
commit
4d5fcca273
8 changed files with 126 additions and 22 deletions
|
@ -1677,27 +1677,6 @@ class Test_ModuleStateAccess(unittest.TestCase):
|
|||
self.assertIs(Subclass().get_defining_module(), self.module)
|
||||
|
||||
|
||||
class Test_FrameAPI(unittest.TestCase):
|
||||
|
||||
def getframe(self):
|
||||
return sys._getframe()
|
||||
|
||||
def getgenframe(self):
|
||||
yield sys._getframe()
|
||||
|
||||
def test_frame_getters(self):
|
||||
frame = self.getframe()
|
||||
self.assertEqual(frame.f_locals, _testcapi.frame_getlocals(frame))
|
||||
self.assertIs(frame.f_globals, _testcapi.frame_getglobals(frame))
|
||||
self.assertIs(frame.f_builtins, _testcapi.frame_getbuiltins(frame))
|
||||
self.assertEqual(frame.f_lasti, _testcapi.frame_getlasti(frame))
|
||||
|
||||
def test_frame_get_generator(self):
|
||||
gen = self.getgenframe()
|
||||
frame = next(gen)
|
||||
self.assertIs(gen, _testcapi.frame_getgenerator(frame))
|
||||
|
||||
|
||||
SUFFICIENT_TO_DEOPT_AND_SPECIALIZE = 100
|
||||
|
||||
class Test_Pep523API(unittest.TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue