When the following functions return ``frame records,'' each record is a tuple of six items: the frame object, the filename, the line number of the current line, the function name, a list of lines of context from the source code, and the index of the current line within that list.
Though the cycle detector will catch these, destruction of the frames (and local variables) can be made deterministic by removing the cycle in a finally clause. This is also important if the cycle detector was disabled when Python was compiled or using gc.disable(). For example:
def handle_stackframe_without_leak(): frame = inspect.currentframe() try: # do something with the frame finally: del frame
The optional context argument supported by most of these functions specifies the number of lines of context to return, which are centered around the current line.
frame[, context]) |
frame[, context]) |
traceback[, context]) |
) |
[context]) |
[context]) |