This is Neil's fix for SF bug 535905 (Evil Trashcan and GC interaction).

The fix makes it possible to call PyObject_GC_UnTrack() more than once
on the same object, and then move the PyObject_GC_UnTrack() call to
*before* the trashcan code is invoked.

BUGFIX CANDIDATE!
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 71e9596..ed25bd4 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -819,7 +819,9 @@
 void
 _PyObject_GC_UnTrack(PyObject *op)
 {
-	_PyObject_GC_UNTRACK(op);
+	PyGC_Head *gc = AS_GC(op);
+	if (gc->gc.gc_next != NULL)
+		_PyObject_GC_UNTRACK(op);
 }
 
 PyObject *