Mailing List Archive

python/dist/src/Doc/lib libinspect.tex,1.10,1.11
Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv27491/lib

Modified Files:
libinspect.tex
Log Message:
Add text about circular references caused by storing frames in local
variables. This closes SF bug #543148.


Index: libinspect.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libinspect.tex,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** libinspect.tex 7 Dec 2001 23:13:53 -0000 1.10
--- libinspect.tex 23 Apr 2002 21:21:20 -0000 1.11
***************
*** 322,323 ****
--- 322,339 ----
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}