File tree Expand file tree Collapse file tree 3 files changed +7
-8
lines changed Expand file tree Collapse file tree 3 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -261,6 +261,7 @@ extern PyGC_Head *_PyGC_generation0;
261
261
262
262
#define _Py_AS_GC (o ) ((PyGC_Head *)(o)-1)
263
263
264
+ /* Bit flags for gc_prev */
264
265
/* Bit 0 is set when tp_finalize is called */
265
266
#define _PyGC_PREV_MASK_FINALIZED (1 << 0)
266
267
/* Bit 1 and 2 is used in gcmodule.c */
@@ -276,13 +277,10 @@ extern PyGC_Head *_PyGC_generation0;
276
277
} while (0)
277
278
278
279
#define _PyGCHead_FINALIZED (g ) (((g)->gc.gc_prev & _PyGC_PREV_MASK_FINALIZED) != 0)
279
- #define _PyGCHead_SET_FINALIZED (g , v ) do { \
280
- (g)->gc.gc_prev = ((g)->gc.gc_prev & ~_PyGC_PREV_MASK_FINALIZED) \
281
- | (v != 0); \
282
- } while (0)
280
+ #define _PyGCHead_SET_FINALIZED (g ) ((g)->gc.gc_prev |= _PyGC_PREV_MASK_FINALIZED)
283
281
284
282
#define _PyGC_FINALIZED (o ) _PyGCHead_FINALIZED(_Py_AS_GC(o))
285
- #define _PyGC_SET_FINALIZED (o , v ) _PyGCHead_SET_FINALIZED(_Py_AS_GC(o), v )
283
+ #define _PyGC_SET_FINALIZED (o ) _PyGCHead_SET_FINALIZED(_Py_AS_GC(o))
286
284
287
285
/* Tell the GC to track this object. NB: While the object is tracked the
288
286
* collector it must be safe to call the ob_traverse method. */
Original file line number Diff line number Diff line change @@ -772,7 +772,7 @@ finalize_garbage(PyGC_Head *collectable)
772
772
if (!_PyGCHead_FINALIZED (gc ) &&
773
773
PyType_HasFeature (Py_TYPE (op ), Py_TPFLAGS_HAVE_FINALIZE ) &&
774
774
(finalize = Py_TYPE (op )-> tp_finalize ) != NULL ) {
775
- _PyGCHead_SET_FINALIZED (gc , 1 );
775
+ _PyGCHead_SET_FINALIZED (gc );
776
776
Py_INCREF (op );
777
777
finalize (op );
778
778
Py_DECREF (op );
Original file line number Diff line number Diff line change @@ -284,8 +284,9 @@ PyObject_CallFinalizer(PyObject *self)
284
284
return ;
285
285
286
286
tp -> tp_finalize (self );
287
- if (PyType_IS_GC (tp ))
288
- _PyGC_SET_FINALIZED (self , 1 );
287
+ if (PyType_IS_GC (tp )) {
288
+ _PyGC_SET_FINALIZED (self );
289
+ }
289
290
}
290
291
291
292
int
You can’t perform that action at this time.
0 commit comments