@@ -1159,47 +1159,81 @@ Frame objects represent execution frames. They may occur in traceback objects
11591159 single: f_lasti (frame attribute)
11601160 single: f_builtins (frame attribute)
11611161
1162- Special read-only attributes: :attr: `f_back ` is to the previous stack frame
1163- (towards the caller), or ``None `` if this is the bottom stack frame;
1164- :attr: `f_code ` is the code object being executed in this frame; :attr: `f_locals `
1165- is the dictionary used to look up local variables; :attr: `f_globals ` is used for
1166- global variables; :attr: `f_builtins ` is used for built-in (intrinsic) names;
1167- :attr: `f_lasti ` gives the precise instruction (this is an index into the
1168- bytecode string of the code object).
1162+ Special read-only attributes
1163+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11691164
1170- Accessing ``f_code `` raises an :ref: `auditing event <auditing >`
1171- ``object.__getattr__ `` with arguments ``obj `` and ``"f_code" ``.
1165+ .. list-table ::
1166+
1167+ * - .. attribute:: frame.f_back
1168+ - Points to the previous stack frame (towards the caller),
1169+ or ``None `` if this is the bottom stack frame
1170+
1171+ * - .. attribute:: frame.f_code
1172+ - The :ref: `code object <code-objects >` being executed in this frame.
1173+ Accessing this attribute raises an :ref: `auditing event <auditing >`
1174+ ``object.__getattr__ `` with arguments ``obj `` and ``"f_code" ``.
1175+
1176+ * - .. attribute:: frame.f_locals
1177+ - The dictionary used by the frame to look up
1178+ :ref: `local variables <naming >`
1179+
1180+ * - .. attribute:: frame.f_globals
1181+ - The dictionary used by the frame to look up
1182+ :ref: `global variables <naming >`
1183+
1184+ * - .. attribute:: frame.f_builtins
1185+ - The dictionary used by the frame to look up
1186+ :ref: `built-in (intrinsic) names <naming >`
1187+
1188+ * - .. attribute:: frame.f_lasti
1189+ - The "precise instruction" of the frame object
1190+ (this is an index into the :term: `bytecode ` string of the
1191+ :ref: `code object <code-objects >`)
11721192
11731193.. index ::
11741194 single: f_trace (frame attribute)
11751195 single: f_trace_lines (frame attribute)
11761196 single: f_trace_opcodes (frame attribute)
11771197 single: f_lineno (frame attribute)
11781198
1179- Special writable attributes: :attr: `f_trace `, if not ``None ``, is a function
1180- called for various events during code execution (this is used by the debugger).
1181- Normally an event is triggered for each new source line - this can be
1182- disabled by setting :attr: `f_trace_lines ` to :const: `False `.
1199+ Special writable attributes
1200+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1201+
1202+ .. list-table ::
1203+
1204+ * - .. attribute:: frame.f_trace
1205+ - If not ``None ``, this is a function called for various events during
1206+ code execution (this is used by debuggers). Normally an event is
1207+ triggered for each new source line (see :attr: `~frame.f_trace_lines `).
1208+
1209+ * - .. attribute:: frame.f_trace_lines
1210+ - Set this attribute to :const: `False ` to disable triggering a tracing
1211+ event for each source line.
1212+
1213+ * - .. attribute:: frame.f_trace_opcodes
1214+ - Set this attribute to :const: `True ` to allow per-opcode events to be
1215+ requested. Note that this may lead to
1216+ undefined interpreter behaviour if exceptions raised by the trace
1217+ function escape to the function being traced.
11831218
1184- Implementations *may * allow per-opcode events to be requested by setting
1185- :attr: `f_trace_opcodes ` to :const: `True `. Note that this may lead to
1186- undefined interpreter behaviour if exceptions raised by the trace
1187- function escape to the function being traced.
1219+ * - .. attribute:: frame.f_lineno
1220+ - The current line number of the frame -- writing to this
1221+ from within a trace function jumps to the given line (only for the bottom-most
1222+ frame). A debugger can implement a Jump command (aka Set Next Statement)
1223+ by writing to this attribute.
11881224
1189- :attr: `f_lineno ` is the current line number of the frame --- writing to this
1190- from within a trace function jumps to the given line (only for the bottom-most
1191- frame). A debugger can implement a Jump command (aka Set Next Statement)
1192- by writing to f_lineno.
1225+ Frame object methods
1226+ ~~~~~~~~~~~~~~~~~~~~
11931227
11941228Frame objects support one method:
11951229
11961230.. method :: frame.clear()
11971231
1198- This method clears all references to local variables held by the
1199- frame. Also, if the frame belonged to a generator, the generator
1232+ This method clears all references to :ref: ` local variables < naming >` held by the
1233+ frame. Also, if the frame belonged to a :term: ` generator ` , the generator
12001234 is finalized. This helps break reference cycles involving frame
1201- objects (for example when catching an exception and storing its
1202- traceback for later use).
1235+ objects (for example when catching an :ref: ` exception < bltin-exceptions >`
1236+ and storing its :ref: ` traceback < traceback-objects >` for later use).
12031237
12041238 :exc: `RuntimeError ` is raised if the frame is currently executing.
12051239
0 commit comments