|
22 | 22 |
|
23 | 23 | #include "Python.h"
|
24 | 24 | #include "datetime.h" // PyDateTimeAPI
|
| 25 | +#include "frameobject.h" // PyFrame_New |
25 | 26 | #include "marshal.h" // PyMarshal_WriteLongToFile
|
26 | 27 | #include "structmember.h" // PyMemberDef
|
27 | 28 | #include <float.h> // FLT_MAX
|
@@ -6000,6 +6001,22 @@ frame_getlasti(PyObject *self, PyObject *frame)
|
6000 | 6001 | return PyLong_FromLong(lasti);
|
6001 | 6002 | }
|
6002 | 6003 |
|
| 6004 | +static PyObject * |
| 6005 | +frame_new(PyObject *self, PyObject *args) |
| 6006 | +{ |
| 6007 | + PyObject *code, *globals, *locals; |
| 6008 | + if (!PyArg_ParseTuple(args, "OOO", &code, &globals, &locals)) { |
| 6009 | + return NULL; |
| 6010 | + } |
| 6011 | + if (!PyCode_Check(code)) { |
| 6012 | + PyErr_SetString(PyExc_TypeError, "argument must be a code object"); |
| 6013 | + return NULL; |
| 6014 | + } |
| 6015 | + PyThreadState *tstate = PyThreadState_Get(); |
| 6016 | + |
| 6017 | + return (PyObject *)PyFrame_New(tstate, (PyCodeObject *)code, globals, locals); |
| 6018 | +} |
| 6019 | + |
6003 | 6020 | static PyObject *
|
6004 | 6021 | eval_get_func_name(PyObject *self, PyObject *func)
|
6005 | 6022 | {
|
@@ -6492,6 +6509,7 @@ static PyMethodDef TestMethods[] = {
|
6492 | 6509 | {"frame_getgenerator", frame_getgenerator, METH_O, NULL},
|
6493 | 6510 | {"frame_getbuiltins", frame_getbuiltins, METH_O, NULL},
|
6494 | 6511 | {"frame_getlasti", frame_getlasti, METH_O, NULL},
|
| 6512 | + {"frame_new", frame_new, METH_VARARGS, NULL}, |
6495 | 6513 | {"eval_get_func_name", eval_get_func_name, METH_O, NULL},
|
6496 | 6514 | {"eval_get_func_desc", eval_get_func_desc, METH_O, NULL},
|
6497 | 6515 | {"get_feature_macros", get_feature_macros, METH_NOARGS, NULL},
|
|
0 commit comments