]> granicus.if.org Git - python/commitdiff
Added info about the right way to leave the body of a trashcan-protected
authorTim Peters <tim.peters@gmail.com>
Wed, 7 Aug 2002 20:53:05 +0000 (20:53 +0000)
committerTim Peters <tim.peters@gmail.com>
Wed, 7 Aug 2002 20:53:05 +0000 (20:53 +0000)
destructor early.

Include/object.h

index 4987e12946812ea93c7d387ea266eb54676b1857..19460fe381c646f64cf40089aafacfe729831efa 100644 (file)
@@ -706,6 +706,11 @@ mytype_dealloc(mytype *p)
        Py_TRASHCAN_SAFE_END(p)
 }
 
+CAUTION:  Never return from the middle of the body!  If the body needs to
+"get out early", put a label immediately before the Py_TRASHCAN_SAFE_END
+call, and goto it.  Else the call-depth counter (see below) will stay
+above 0 forever, and the trashcan will never get emptied.
+
 How it works:  The BEGIN macro increments a call-depth counter.  So long
 as this counter is small, the body of the deallocator is run directly without
 further ado.  But if the counter gets large, it instead adds p to a list of