@@ -2569,7 +2569,7 @@ subtype_dealloc(PyObject *self)
2569
2569
_PyObject_GC_TRACK (self );
2570
2570
if (PyObject_CallFinalizerFromDealloc (self ) < 0 ) {
2571
2571
/* Resurrected */
2572
- goto endlabel ;
2572
+ return ;
2573
2573
}
2574
2574
_PyObject_GC_UNTRACK (self );
2575
2575
}
@@ -2591,7 +2591,7 @@ subtype_dealloc(PyObject *self)
2591
2591
type -> tp_del (self );
2592
2592
if (Py_REFCNT (self ) > 0 ) {
2593
2593
/* Resurrected */
2594
- goto endlabel ;
2594
+ return ;
2595
2595
}
2596
2596
_PyObject_GC_UNTRACK (self );
2597
2597
}
@@ -2655,44 +2655,6 @@ subtype_dealloc(PyObject *self)
2655
2655
_Py_DECREF_TYPE (type );
2656
2656
}
2657
2657
2658
- endlabel :
2659
-
2660
- /* Explanation of the weirdness around the trashcan macros:
2661
-
2662
- Q. What do the trashcan macros do?
2663
-
2664
- A. Read the comment titled "Trashcan mechanism" in object.h.
2665
- For one, this explains why there must be a call to GC-untrack
2666
- before the trashcan begin macro. Without understanding the
2667
- trashcan code, the answers to the following questions don't make
2668
- sense.
2669
-
2670
- Q. Why do we GC-untrack before the trashcan and then immediately
2671
- GC-track again afterward?
2672
-
2673
- A. In the case that the base class is GC-aware, the base class
2674
- probably GC-untracks the object. If it does that using the
2675
- UNTRACK macro, this will crash when the object is already
2676
- untracked. Because we don't know what the base class does, the
2677
- only safe thing is to make sure the object is tracked when we
2678
- call the base class dealloc. But... The trashcan begin macro
2679
- requires that the object is *untracked* before it is called. So
2680
- the dance becomes:
2681
-
2682
- GC untrack
2683
- trashcan begin
2684
- GC track
2685
-
2686
- Q. Why did the last question say "immediately GC-track again"?
2687
- It's nowhere near immediately.
2688
-
2689
- A. Because the code *used* to re-track immediately. Bad Idea.
2690
- self has a refcount of 0, and if gc ever gets its hands on it
2691
- (which can happen if any weakref callback gets invoked), it
2692
- looks like trash to gc too, and gc also tries to delete self
2693
- then. But we're already deleting self. Double deallocation is
2694
- a subtle disaster.
2695
- */
2696
2658
}
2697
2659
2698
2660
static PyTypeObject * solid_base (PyTypeObject * type );
0 commit comments