diff options
author | Fred Drake <fdrake@acm.org> | 2002-04-23 21:21:20 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-04-23 21:21:20 (GMT) |
commit | 99d17006c12d2e768a7b8e1c706adf6b4e152140 (patch) | |
tree | 6f964ca7bf9efe1786c58abfd354f75dfacdc3be /Doc/lib | |
parent | 95df3fd15933dafbb2f1140d011794cc8ccbdc76 (diff) | |
download | cpython-99d17006c12d2e768a7b8e1c706adf6b4e152140.zip cpython-99d17006c12d2e768a7b8e1c706adf6b4e152140.tar.gz cpython-99d17006c12d2e768a7b8e1c706adf6b4e152140.tar.bz2 |
Add text about circular references caused by storing frames in local
variables. This closes SF bug #543148.
Diffstat (limited to 'Doc/lib')
-rw-r--r-- | Doc/lib/libinspect.tex | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Doc/lib/libinspect.tex b/Doc/lib/libinspect.tex index 186fd58..a1293f0 100644 --- a/Doc/lib/libinspect.tex +++ b/Doc/lib/libinspect.tex @@ -321,3 +321,19 @@ which occurs.} Return a list of frame records for the stack below the current exception. \end{funcdesc} + +Stackframes stored directly or indirectly in local variables can +easily cause reference cycles. Though the cycle detector will catch +these, destruction of the frames (and local variables) can be made +deterministic by removing the cycle in a \keyword{finally} clause. +This is also important if the cycle detector was disabled when Python +was compiled or using \function{gc.disable()}. For example: + +\begin{verbatim} +def handle_stackframe_without_leak(): + frame = inspect.currentframe() + try: + # do something with the frame + finally: + del frame +\end{verbatim} |