blob: 594c1ec7943f750d9fcc5e71ccd32123fa526b83 [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
36 Return a borrowed reference to the *frame* code.
Victor Stinner6d86a232020-04-29 00:56:58 +020037 The frame code cannot be ``NULL``.
Victor Stinnera42ca742020-04-28 19:01:31 +020038
39 *frame* must not be ``NULL``.
40
41 .. versionadded:: 3.9
42
43
Georg Brandl60203b42010-10-06 10:11:56 +000044.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
Alexandre Vassalotti7b82b402009-07-21 04:30:03 +000045
46 Return the line number that *frame* is currently executing.
47
Victor Stinner7c59d7c2020-04-28 16:32:48 +020048 *frame* must not be ``NULL``.
49
Alexandre Vassalotti7b82b402009-07-21 04:30:03 +000050
Georg Brandl60203b42010-10-06 10:11:56 +000051.. c:function:: const char* PyEval_GetFuncName(PyObject *func)
Georg Brandl54a3faa2008-01-20 09:30:57 +000052
53 Return the name of *func* if it is a function, class or instance object, else the
54 name of *func*\s type.
55
56
Georg Brandl60203b42010-10-06 10:11:56 +000057.. c:function:: const char* PyEval_GetFuncDesc(PyObject *func)
Georg Brandl54a3faa2008-01-20 09:30:57 +000058
59 Return a description string, depending on the type of *func*.
60 Return values include "()" for functions and methods, " constructor",
61 " instance", and " object". Concatenated with the result of
Georg Brandl60203b42010-10-06 10:11:56 +000062 :c:func:`PyEval_GetFuncName`, the result will be a description of
Georg Brandl54a3faa2008-01-20 09:30:57 +000063 *func*.