@@ -1174,47 +1174,81 @@ Frame objects represent execution frames. They may occur in traceback objects
11741174 single: f_lasti (frame attribute)
11751175 single: f_builtins (frame attribute)
11761176
1177- Special read-only attributes: :attr: `f_back ` is to the previous stack frame
1178- (towards the caller), or ``None `` if this is the bottom stack frame;
1179- :attr: `f_code ` is the code object being executed in this frame; :attr: `f_locals `
1180- is the dictionary used to look up local variables; :attr: `f_globals ` is used for
1181- global variables; :attr: `f_builtins ` is used for built-in (intrinsic) names;
1182- :attr: `f_lasti ` gives the precise instruction (this is an index into the
1183- bytecode string of the code object).
1177+ Special read-only attributes
1178+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11841179
1185- Accessing ``f_code `` raises an :ref: `auditing event <auditing >`
1186- ``object.__getattr__ `` with arguments ``obj `` and ``"f_code" ``.
1180+ .. list-table ::
1181+
1182+ * - .. attribute:: frame.f_back
1183+ - Points to the previous stack frame (towards the caller),
1184+ or ``None `` if this is the bottom stack frame
1185+
1186+ * - .. attribute:: frame.f_code
1187+ - The :ref: `code object <code-objects >` being executed in this frame.
1188+ Accessing this attribute raises an :ref: `auditing event <auditing >`
1189+ ``object.__getattr__ `` with arguments ``obj `` and ``"f_code" ``.
1190+
1191+ * - .. attribute:: frame.f_locals
1192+ - The dictionary used by the frame to look up
1193+ :ref: `local variables <naming >`
1194+
1195+ * - .. attribute:: frame.f_globals
1196+ - The dictionary used by the frame to look up
1197+ :ref: `global variables <naming >`
1198+
1199+ * - .. attribute:: frame.f_builtins
1200+ - The dictionary used by the frame to look up
1201+ :ref: `built-in (intrinsic) names <naming >`
1202+
1203+ * - .. attribute:: frame.f_lasti
1204+ - The "precise instruction" of the frame object
1205+ (this is an index into the :term: `bytecode ` string of the
1206+ :ref: `code object <code-objects >`)
11871207
11881208.. index ::
11891209 single: f_trace (frame attribute)
11901210 single: f_trace_lines (frame attribute)
11911211 single: f_trace_opcodes (frame attribute)
11921212 single: f_lineno (frame attribute)
11931213
1194- Special writable attributes: :attr: `f_trace `, if not ``None ``, is a function
1195- called for various events during code execution (this is used by the debugger).
1196- Normally an event is triggered for each new source line - this can be
1197- disabled by setting :attr: `f_trace_lines ` to :const: `False `.
1214+ Special writable attributes
1215+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1216+
1217+ .. list-table ::
1218+
1219+ * - .. attribute:: frame.f_trace
1220+ - If not ``None ``, this is a function called for various events during
1221+ code execution (this is used by debuggers). Normally an event is
1222+ triggered for each new source line (see :attr: `~frame.f_trace_lines `).
1223+
1224+ * - .. attribute:: frame.f_trace_lines
1225+ - Set this attribute to :const: `False ` to disable triggering a tracing
1226+ event for each source line.
1227+
1228+ * - .. attribute:: frame.f_trace_opcodes
1229+ - Set this attribute to :const: `True ` to allow per-opcode events to be
1230+ requested. Note that this may lead to
1231+ undefined interpreter behaviour if exceptions raised by the trace
1232+ function escape to the function being traced.
11981233
1199- Implementations *may * allow per-opcode events to be requested by setting
1200- :attr: `f_trace_opcodes ` to :const: `True `. Note that this may lead to
1201- undefined interpreter behaviour if exceptions raised by the trace
1202- function escape to the function being traced.
1234+ * - .. attribute:: frame.f_lineno
1235+ - The current line number of the frame -- writing to this
1236+ from within a trace function jumps to the given line (only for the bottom-most
1237+ frame). A debugger can implement a Jump command (aka Set Next Statement)
1238+ by writing to this attribute.
12031239
1204- :attr: `f_lineno ` is the current line number of the frame --- writing to this
1205- from within a trace function jumps to the given line (only for the bottom-most
1206- frame). A debugger can implement a Jump command (aka Set Next Statement)
1207- by writing to f_lineno.
1240+ Frame object methods
1241+ ~~~~~~~~~~~~~~~~~~~~
12081242
12091243Frame objects support one method:
12101244
12111245.. method :: frame.clear()
12121246
1213- This method clears all references to local variables held by the
1214- frame. Also, if the frame belonged to a generator, the generator
1247+ This method clears all references to :ref: ` local variables < naming >` held by the
1248+ frame. Also, if the frame belonged to a :term: ` generator ` , the generator
12151249 is finalized. This helps break reference cycles involving frame
1216- objects (for example when catching an exception and storing its
1217- traceback for later use).
1250+ objects (for example when catching an :ref: ` exception < bltin-exceptions >`
1251+ and storing its :ref: ` traceback < traceback-objects >` for later use).
12181252
12191253 :exc: `RuntimeError ` is raised if the frame is currently executing
12201254 or suspended.
0 commit comments