blob: 21d9878609127182368139203bfd7bd779dd7aa1 [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 Stinnera42ca742020-04-28 19:01:31 +020034.. c:function:: int PyFrame_GetCode(PyFrameObject *frame)
35
Victor Stinner8852ad42020-04-29 01:28:13 +020036 Get the *frame* code.
Victor Stinnera42ca742020-04-28 19:01:31 +020037
Victor Stinner8852ad42020-04-29 01:28:13 +020038 Return a strong reference.
39
40 *frame* must not be ``NULL``. The result (frame code) cannot be ``NULL``.
Victor Stinnera42ca742020-04-28 19:01:31 +020041
42 .. versionadded:: 3.9
43
44
Georg Brandl60203b42010-10-06 10:11:56 +000045.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
Alexandre Vassalotti7b82b402009-07-21 04:30:03 +000046
47 Return the line number that *frame* is currently executing.
48
Victor Stinner7c59d7c2020-04-28 16:32:48 +020049 *frame* must not be ``NULL``.
50
Alexandre Vassalotti7b82b402009-07-21 04:30:03 +000051
Georg Brandl60203b42010-10-06 10:11:56 +000052.. c:function:: const char* PyEval_GetFuncName(PyObject *func)
Georg Brandl54a3faa2008-01-20 09:30:57 +000053
54 Return the name of *func* if it is a function, class or instance object, else the
55 name of *func*\s type.
56
57
Georg Brandl60203b42010-10-06 10:11:56 +000058.. c:function:: const char* PyEval_GetFuncDesc(PyObject *func)
Georg Brandl54a3faa2008-01-20 09:30:57 +000059
60 Return a description string, depending on the type of *func*.
61 Return values include "()" for functions and methods, " constructor",
62 " instance", and " object". Concatenated with the result of
Georg Brandl60203b42010-10-06 10:11:56 +000063 :c:func:`PyEval_GetFuncName`, the result will be a description of
Georg Brandl54a3faa2008-01-20 09:30:57 +000064 *func*.