反射

PyObject* PyEval_GetBuiltins()
Return value: Borrowed reference.

返回当前执行帧中内置函数的字典,如果当前没有帧正在执行,则返回线程状态的解释器。

PyObject* PyEval_GetLocals()
Return value: Borrowed reference.

Return a dictionary of the local variables in the current execution frame, or NULL if no frame is currently executing.

PyObject* PyEval_GetGlobals()
Return value: Borrowed reference.

Return a dictionary of the global variables in the current execution frame, or NULL if no frame is currently executing.

PyFrameObject* PyEval_GetFrame()
Return value: Borrowed reference.

Return the current thread state’s frame, which is NULL if no frame is currently executing.

int PyFrame_GetLineNumber(PyFrameObject *frame)

返回 frame 当前正在执行的行号。

int PyEval_GetRestricted()

If there is a current frame and it is executing in restricted mode, return true, otherwise false.

const char* PyEval_GetFuncName(PyObject *func)

如果 func 是函数、类或实例对象,则返回它的名称,否则返回 func 的类型的名称。

const char* PyEval_GetFuncDesc(PyObject *func)

根据 func 的类型返回描述字符串。 返回值包括函数和方法的 “()”, ” constructor”, ” instance” 和 ” object”。 与 PyEval_GetFuncName() 的结果连接,结果将是 func 的描述。