diff options
author | Mark Shannon <mark@hotpy.org> | 2022-04-08 11:18:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-08 11:18:57 (GMT) |
commit | 5b4a4b6f0905c60514528b454af43aeea058b5a2 (patch) | |
tree | ab395cfccfecb94af2db5055f7477ddb39a9ea3e /Modules/_testcapimodule.c | |
parent | f4b328e2bbbcc1096a28e903f07868b425397767 (diff) | |
download | cpython-5b4a4b6f0905c60514528b454af43aeea058b5a2.zip cpython-5b4a4b6f0905c60514528b454af43aeea058b5a2.tar.gz cpython-5b4a4b6f0905c60514528b454af43aeea058b5a2.tar.bz2 |
Add new PyFrame_GetLasti C-API function (GH-32413)
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 759656a..13dd294 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -5893,6 +5893,21 @@ frame_getbuiltins(PyObject *self, PyObject *frame) return PyFrame_GetBuiltins((PyFrameObject *)frame); } +static PyObject * +frame_getlasti(PyObject *self, PyObject *frame) +{ + if (!PyFrame_Check(frame)) { + PyErr_SetString(PyExc_TypeError, "argument must be a frame"); + return NULL; + } + int lasti = PyFrame_GetLasti((PyFrameObject *)frame); + if (lasti < 0) { + assert(lasti == -1); + Py_RETURN_NONE; + } + return PyLong_FromLong(lasti); +} + static PyObject *negative_dictoffset(PyObject *, PyObject *); static PyObject *test_buildvalue_issue38913(PyObject *, PyObject *); @@ -6186,6 +6201,7 @@ static PyMethodDef TestMethods[] = { {"frame_getglobals", frame_getglobals, METH_O, NULL}, {"frame_getgenerator", frame_getgenerator, METH_O, NULL}, {"frame_getbuiltins", frame_getbuiltins, METH_O, NULL}, + {"frame_getlasti", frame_getlasti, METH_O, NULL}, {NULL, NULL} /* sentinel */ }; |