summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-08-07 20:53:05 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-08-07 20:53:05 (GMT)
commit808eb59fc46f031939d23b07be4d705905d317e4 (patch)
tree13c8c2ba370b19449ef4c3fb90c68207d4495a34
parent0906e074426fc596cffb157e28be4bf82de62c7b (diff)
downloadcpython-808eb59fc46f031939d23b07be4d705905d317e4.zip
cpython-808eb59fc46f031939d23b07be4d705905d317e4.tar.gz
cpython-808eb59fc46f031939d23b07be4d705905d317e4.tar.bz2
Added info about the right way to leave the body of a trashcan-protected
destructor early.
-rw-r--r--Include/object.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/Include/object.h b/Include/object.h
index 4987e12..19460fe 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -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