diff options
author | Mark Shannon <mark@hotpy.org> | 2022-03-31 16:13:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-31 16:13:25 (GMT) |
commit | 74b95d86e0f14603f878c4df3133bc8a93f8f80a (patch) | |
tree | bdd3f8b2a671bfa2458c1a4e34098ff70fa6e36b /Objects/frameobject.c | |
parent | 44e915028d75f7cef141aa1aada962465a5907d6 (diff) | |
download | cpython-74b95d86e0f14603f878c4df3133bc8a93f8f80a.zip cpython-74b95d86e0f14603f878c4df3133bc8a93f8f80a.tar.gz cpython-74b95d86e0f14603f878c4df3133bc8a93f8f80a.tar.bz2 |
bpo-40421: Add missing getters for frame object attributes to C-API. (GH-32114)
Diffstat (limited to 'Objects/frameobject.c')
-rw-r--r-- | Objects/frameobject.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c index d4993104..581de22 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -1135,6 +1135,28 @@ PyFrame_GetLocals(PyFrameObject *frame) } PyObject* +PyFrame_GetGlobals(PyFrameObject *frame) +{ + return frame_getglobals(frame, NULL); +} + +PyObject* +PyFrame_GetBuiltins(PyFrameObject *frame) +{ + return frame_getbuiltins(frame, NULL); +} + +PyObject * +PyFrame_GetGenerator(PyFrameObject *frame) +{ + if (frame->f_frame->owner != FRAME_OWNED_BY_GENERATOR) { + return NULL; + } + PyGenObject *gen = _PyFrame_GetGenerator(frame->f_frame); + return Py_NewRef(gen); +} + +PyObject* _PyEval_BuiltinsFromGlobals(PyThreadState *tstate, PyObject *globals) { PyObject *builtins = PyDict_GetItemWithError(globals, &_Py_ID(__builtins__)); |