[Python-checkins] python/dist/src/Modules gcmodule.c,2.53,2.54

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Sat, 06 Jul 2002 22:13:58 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv27054/python/Modules

Modified Files:
	gcmodule.c 
Log Message:
Trashcan cleanup:  Now that cyclic gc is always there, the trashcan
mechanism is no longer evil:  it no longer plays dangerous games with
the type pointer or refcounts, and objects in extension modules can play
along too without needing to edit the core first.

Rewrote all the comments to explain this, and (I hope) give clear
guidance to extension authors who do want to play along.  Documented
all the functions.  Added more asserts (it may no longer be evil, but
it's still dangerous <0.9 wink>).  Rearranged the generated code to
make it clearer, and to tolerate either the presence or absence of a
semicolon after the macros.  Rewrote _PyTrash_destroy_chain() to call
tp_dealloc directly; it was doing a Py_DECREF again, and that has all
sorts of obscure distorting effects in non-release builds (Py_DECREF
was already called on the object!).  Removed Christian's little "embedded
change log" comments -- that's what checkin messages are for, and since
it was impossible to correlate the comments with the code that changed,
I found them merely distracting.


Index: gcmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v
retrieving revision 2.53
retrieving revision 2.54
diff -C2 -d -r2.53 -r2.54
*** gcmodule.c	7 Jul 2002 03:59:34 -0000	2.53
--- gcmodule.c	7 Jul 2002 05:13:56 -0000	2.54
***************
*** 964,967 ****
--- 964,970 ----
  PyObject_GC_UnTrack(void *op)
  {
+ 	/* Obscure:  the Py_TRASHCAN mechanism requires that we be able to
+ 	 * call PyObject_GC_UnTrack twice on an object.
+ 	 */
  	if (IS_TRACKED(op))
  		_PyObject_GC_UNTRACK(op);