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 | 7036477 | 2020-04-29 03:28:46 +0200 | [diff] [blame] | 34 | .. 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 Stinner | a42ca74 | 2020-04-28 19:01:31 +0200 | [diff] [blame] | 45 | .. c:function:: int PyFrame_GetCode(PyFrameObject *frame) |
| 46 | |
Victor Stinner | 8852ad4 | 2020-04-29 01:28:13 +0200 | [diff] [blame] | 47 | Get the *frame* code. |
Victor Stinner | a42ca74 | 2020-04-28 19:01:31 +0200 | [diff] [blame] | 48 | |
Victor Stinner | 8852ad4 | 2020-04-29 01:28:13 +0200 | [diff] [blame] | 49 | Return a strong reference. |
| 50 | |
| 51 | *frame* must not be ``NULL``. The result (frame code) cannot be ``NULL``. |
Victor Stinner | a42ca74 | 2020-04-28 19:01:31 +0200 | [diff] [blame] | 52 | |
| 53 | .. versionadded:: 3.9 |
| 54 | |
| 55 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 56 | .. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame) |
Alexandre Vassalotti | 7b82b40 | 2009-07-21 04:30:03 +0000 | [diff] [blame] | 57 | |
| 58 | Return the line number that *frame* is currently executing. |
| 59 | |
Victor Stinner | 7c59d7c | 2020-04-28 16:32:48 +0200 | [diff] [blame] | 60 | *frame* must not be ``NULL``. |
| 61 | |
Alexandre Vassalotti | 7b82b40 | 2009-07-21 04:30:03 +0000 | [diff] [blame] | 62 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 63 | .. c:function:: const char* PyEval_GetFuncName(PyObject *func) |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 64 | |
| 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 Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 69 | .. c:function:: const char* PyEval_GetFuncDesc(PyObject *func) |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 70 | |
| 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 Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 74 | :c:func:`PyEval_GetFuncName`, the result will be a description of |
Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 75 | *func*. |