blob: 9207d86012c8b338175ba72b849510b7d8edb8c4 [file] [log] [blame]
Stéphane Wirtelcbb64842019-05-17 11:55:34 +02001.. highlight:: c
Georg Brandl54a3faa2008-01-20 09:30:57 +00002
3.. _reflection:
4
5Reflection
6==========
7
Victor Stinnerfd1e1a12020-03-20 15:51:45 +01008.. c:function:: PyObject* PyEval_GetBuiltins(void)
Georg Brandl54a3faa2008-01-20 09:30:57 +00009
10 Return a dictionary of the builtins in the current execution frame,
11 or the interpreter of the thread state if no frame is currently executing.
12
13
Victor Stinnerfd1e1a12020-03-20 15:51:45 +010014.. c:function:: PyObject* PyEval_GetLocals(void)
Georg Brandl54a3faa2008-01-20 09:30:57 +000015
16 Return a dictionary of the local variables in the current execution frame,
Serhiy Storchaka25fc0882019-10-30 12:03:20 +020017 or ``NULL`` if no frame is currently executing.
Georg Brandl48310cd2009-01-03 21:18:54 +000018
Georg Brandl54a3faa2008-01-20 09:30:57 +000019
Victor Stinnerfd1e1a12020-03-20 15:51:45 +010020.. c:function:: PyObject* PyEval_GetGlobals(void)
Georg Brandl54a3faa2008-01-20 09:30:57 +000021
22 Return a dictionary of the global variables in the current execution frame,
Serhiy Storchaka25fc0882019-10-30 12:03:20 +020023 or ``NULL`` if no frame is currently executing.
Georg Brandl54a3faa2008-01-20 09:30:57 +000024
25
Victor Stinnerfd1e1a12020-03-20 15:51:45 +010026.. c:function:: PyFrameObject* PyEval_GetFrame(void)
Georg Brandl54a3faa2008-01-20 09:30:57 +000027
Serhiy Storchaka25fc0882019-10-30 12:03:20 +020028 Return the current thread state's frame, which is ``NULL`` if no frame is
Georg Brandl54a3faa2008-01-20 09:30:57 +000029 currently executing.
30
Victor Stinnerfd1e1a12020-03-20 15:51:45 +010031 See also :c:func:`PyThreadState_GetFrame`.
32
Georg Brandl54a3faa2008-01-20 09:30:57 +000033
Victor Stinner70364772020-04-29 03:28:46 +020034.. c:function:: int PyFrame_GetBack(PyFrameObject *frame)
35
36 Get the *frame* next outer frame.
37
38 Return a strong reference, or ``NULL`` if *frame* has no outer frame.
39
40 *frame* must not be ``NULL``.
41
42 .. versionadded:: 3.9
43
44
Victor Stinnera42ca742020-04-28 19:01:31 +020045.. c:function:: int PyFrame_GetCode(PyFrameObject *frame)
46
Victor Stinner8852ad42020-04-29 01:28:13 +020047 Get the *frame* code.
Victor Stinnera42ca742020-04-28 19:01:31 +020048
Victor Stinner8852ad42020-04-29 01:28:13 +020049 Return a strong reference.
50
51 *frame* must not be ``NULL``. The result (frame code) cannot be ``NULL``.
Victor Stinnera42ca742020-04-28 19:01:31 +020052
53 .. versionadded:: 3.9
54
55
Georg Brandl60203b42010-10-06 10:11:56 +000056.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
Alexandre Vassalotti7b82b402009-07-21 04:30:03 +000057
58 Return the line number that *frame* is currently executing.
59
Victor Stinner7c59d7c2020-04-28 16:32:48 +020060 *frame* must not be ``NULL``.
61
Alexandre Vassalotti7b82b402009-07-21 04:30:03 +000062
Georg Brandl60203b42010-10-06 10:11:56 +000063.. c:function:: const char* PyEval_GetFuncName(PyObject *func)
Georg Brandl54a3faa2008-01-20 09:30:57 +000064
65 Return the name of *func* if it is a function, class or instance object, else the
66 name of *func*\s type.
67
68
Georg Brandl60203b42010-10-06 10:11:56 +000069.. c:function:: const char* PyEval_GetFuncDesc(PyObject *func)
Georg Brandl54a3faa2008-01-20 09:30:57 +000070
71 Return a description string, depending on the type of *func*.
72 Return values include "()" for functions and methods, " constructor",
73 " instance", and " object". Concatenated with the result of
Georg Brandl60203b42010-10-06 10:11:56 +000074 :c:func:`PyEval_GetFuncName`, the result will be a description of
Georg Brandl54a3faa2008-01-20 09:30:57 +000075 *func*.