Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ce20967

Browse files
committed
Don't remove instance objects from the GC container set until we are
they are dead. Fixes bug #113812.
1 parent e64572b commit ce20967

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

Objects/classobject.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ instance_dealloc(register PyInstanceObject *inst)
490490
#ifdef Py_TRACE_REFS
491491
extern long _Py_RefTotal;
492492
#endif
493-
PyObject_GC_Fini(inst);
494493
/* Call the __del__ method if it exists. First temporarily
495494
revive the object and save the current exception, if any. */
496495
#ifdef Py_TRACE_REFS
@@ -523,7 +522,6 @@ instance_dealloc(register PyInstanceObject *inst)
523522
#ifdef COUNT_ALLOCS
524523
inst->ob_type->tp_free--;
525524
#endif
526-
PyObject_GC_Init((PyObject *)inst);
527525
return; /* __del__ added a reference; don't delete now */
528526
}
529527
#ifdef Py_TRACE_REFS
@@ -535,6 +533,7 @@ instance_dealloc(register PyInstanceObject *inst)
535533
inst->ob_type = NULL;
536534
#endif
537535
#endif /* Py_TRACE_REFS */
536+
PyObject_GC_Fini(inst);
538537
Py_DECREF(inst->in_class);
539538
Py_XDECREF(inst->in_dict);
540539
inst = (PyInstanceObject *) PyObject_AS_GC(inst);

0 commit comments

Comments
 (0)