Stéphane Wirtel | cbb6484 | 2019-05-17 11:55:34 +0200 | [diff] [blame] | 1 | .. highlight:: c |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 2 | |
| 3 | .. _reflection: |
| 4 | |
| 5 | Reflection |
| 6 | ========== |
| 7 | |
Victor Stinner | fd1e1a1 | 2020-03-20 15:51:45 +0100 | [diff] [blame] | 8 | .. c:function:: PyObject* PyEval_GetBuiltins(void) |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 9 | |
| 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 Stinner | fd1e1a1 | 2020-03-20 15:51:45 +0100 | [diff] [blame] | 14 | .. c:function:: PyObject* PyEval_GetLocals(void) |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 15 | |
| 16 | Return a dictionary of the local variables in the current execution frame, |
Serhiy Storchaka | 25fc088 | 2019-10-30 12:03:20 +0200 | [diff] [blame] | 17 | or ``NULL`` if no frame is currently executing. |
Georg Brandl | 48310cd | 2009-01-03 21:18:54 +0000 | [diff] [blame] | 18 | |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 19 | |
Victor Stinner | fd1e1a1 | 2020-03-20 15:51:45 +0100 | [diff] [blame] | 20 | .. c:function:: PyObject* PyEval_GetGlobals(void) |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 21 | |
| 22 | Return a dictionary of the global variables in the current execution frame, |
Serhiy Storchaka | 25fc088 | 2019-10-30 12:03:20 +0200 | [diff] [blame] | 23 | or ``NULL`` if no frame is currently executing. |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 24 | |
| 25 | |
Victor Stinner | fd1e1a1 | 2020-03-20 15:51:45 +0100 | [diff] [blame] | 26 | .. c:function:: PyFrameObject* PyEval_GetFrame(void) |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 27 | |
Serhiy Storchaka | 25fc088 | 2019-10-30 12:03:20 +0200 | [diff] [blame] | 28 | Return the current thread state's frame, which is ``NULL`` if no frame is |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 29 | currently executing. |
| 30 | |
Victor Stinner | fd1e1a1 | 2020-03-20 15:51:45 +0100 | [diff] [blame] | 31 | See also :c:func:`PyThreadState_GetFrame`. |
| 32 | |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 33 | |
Victor Stinner | a42ca74 | 2020-04-28 19:01:31 +0200 | [diff] [blame] | 34 | .. c:function:: int PyFrame_GetCode(PyFrameObject *frame) |
| 35 | |
| 36 | Return a borrowed reference to the *frame* code. |
Victor Stinner | 6d86a23 | 2020-04-29 00:56:58 +0200 | [diff] [blame^] | 37 | The frame code cannot be ``NULL``. |
Victor Stinner | a42ca74 | 2020-04-28 19:01:31 +0200 | [diff] [blame] | 38 | |
| 39 | *frame* must not be ``NULL``. |
| 40 | |
| 41 | .. versionadded:: 3.9 |
| 42 | |
| 43 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 44 | .. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame) |
Alexandre Vassalotti | 7b82b40 | 2009-07-21 04:30:03 +0000 | [diff] [blame] | 45 | |
| 46 | Return the line number that *frame* is currently executing. |
| 47 | |
Victor Stinner | 7c59d7c | 2020-04-28 16:32:48 +0200 | [diff] [blame] | 48 | *frame* must not be ``NULL``. |
| 49 | |
Alexandre Vassalotti | 7b82b40 | 2009-07-21 04:30:03 +0000 | [diff] [blame] | 50 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 51 | .. c:function:: const char* PyEval_GetFuncName(PyObject *func) |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 52 | |
| 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 Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 57 | .. c:function:: const char* PyEval_GetFuncDesc(PyObject *func) |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 58 | |
| 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 Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 62 | :c:func:`PyEval_GetFuncName`, the result will be a description of |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 63 | *func*. |