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 /Modules/_testcapimodule.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 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 019c2b8..759656a 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -5853,6 +5853,46 @@ test_float_unpack(PyObject *self, PyObject *args) return PyFloat_FromDouble(d); } +static PyObject * +frame_getlocals(PyObject *self, PyObject *frame) +{ + if (!PyFrame_Check(frame)) { + PyErr_SetString(PyExc_TypeError, "argument must be a frame"); + return NULL; + } + return PyFrame_GetLocals((PyFrameObject *)frame); +} + +static PyObject * +frame_getglobals(PyObject *self, PyObject *frame) +{ + if (!PyFrame_Check(frame)) { + PyErr_SetString(PyExc_TypeError, "argument must be a frame"); + return NULL; + } + return PyFrame_GetGlobals((PyFrameObject *)frame); +} + +static PyObject * +frame_getgenerator(PyObject *self, PyObject *frame) +{ + if (!PyFrame_Check(frame)) { + PyErr_SetString(PyExc_TypeError, "argument must be a frame"); + return NULL; + } + return PyFrame_GetGenerator((PyFrameObject *)frame); +} + +static PyObject * +frame_getbuiltins(PyObject *self, PyObject *frame) +{ + if (!PyFrame_Check(frame)) { + PyErr_SetString(PyExc_TypeError, "argument must be a frame"); + return NULL; + } + return PyFrame_GetBuiltins((PyFrameObject *)frame); +} + static PyObject *negative_dictoffset(PyObject *, PyObject *); static PyObject *test_buildvalue_issue38913(PyObject *, PyObject *); @@ -6142,6 +6182,10 @@ static PyMethodDef TestMethods[] = { {"test_tstate_capi", test_tstate_capi, METH_NOARGS, NULL}, {"float_pack", test_float_pack, METH_VARARGS, NULL}, {"float_unpack", test_float_unpack, METH_VARARGS, NULL}, + {"frame_getlocals", frame_getlocals, METH_O, NULL}, + {"frame_getglobals", frame_getglobals, METH_O, NULL}, + {"frame_getgenerator", frame_getgenerator, METH_O, NULL}, + {"frame_getbuiltins", frame_getbuiltins, METH_O, NULL}, {NULL, NULL} /* sentinel */ }; |