|
|
@ -3551,7 +3551,7 @@ slot_tp_del(PyObject *self) |
|
|
|
|
|
|
|
|
/* Temporarily resurrect the object. */ |
|
|
/* Temporarily resurrect the object. */ |
|
|
assert(Py_REFCNT(self) == 0); |
|
|
assert(Py_REFCNT(self) == 0); |
|
|
Py_REFCNT(self) = 1; |
|
|
|
|
|
|
|
|
Py_SET_REFCNT(self, 1); |
|
|
|
|
|
|
|
|
/* Save the current exception, if any. */ |
|
|
/* Save the current exception, if any. */ |
|
|
PyErr_Fetch(&error_type, &error_value, &error_traceback); |
|
|
PyErr_Fetch(&error_type, &error_value, &error_traceback); |
|
|
@ -3574,7 +3574,8 @@ slot_tp_del(PyObject *self) |
|
|
* cause a recursive call. |
|
|
* cause a recursive call. |
|
|
*/ |
|
|
*/ |
|
|
assert(Py_REFCNT(self) > 0); |
|
|
assert(Py_REFCNT(self) > 0); |
|
|
if (--Py_REFCNT(self) == 0) { |
|
|
|
|
|
|
|
|
Py_SET_REFCNT(self, Py_REFCNT(self) - 1); |
|
|
|
|
|
if (Py_REFCNT(self) == 0) { |
|
|
/* this is the normal path out */ |
|
|
/* this is the normal path out */ |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
@ -3585,7 +3586,7 @@ slot_tp_del(PyObject *self) |
|
|
{ |
|
|
{ |
|
|
Py_ssize_t refcnt = Py_REFCNT(self); |
|
|
Py_ssize_t refcnt = Py_REFCNT(self); |
|
|
_Py_NewReference(self); |
|
|
_Py_NewReference(self); |
|
|
Py_REFCNT(self) = refcnt; |
|
|
|
|
|
|
|
|
Py_SET_REFCNT(self, refcnt); |
|
|
} |
|
|
} |
|
|
assert(!PyType_IS_GC(Py_TYPE(self)) || _PyObject_GC_IS_TRACKED(self)); |
|
|
assert(!PyType_IS_GC(Py_TYPE(self)) || _PyObject_GC_IS_TRACKED(self)); |
|
|
/* If Py_REF_DEBUG macro is defined, _Py_NewReference() increased |
|
|
/* If Py_REF_DEBUG macro is defined, _Py_NewReference() increased |
|
|
@ -4621,7 +4622,7 @@ check_pyobject_uninitialized_is_freed(PyObject *self, PyObject *Py_UNUSED(args)) |
|
|
return NULL; |
|
|
return NULL; |
|
|
} |
|
|
} |
|
|
/* Initialize reference count to avoid early crash in ceval or GC */ |
|
|
/* Initialize reference count to avoid early crash in ceval or GC */ |
|
|
Py_REFCNT(op) = 1; |
|
|
|
|
|
|
|
|
Py_SET_REFCNT(op, 1); |
|
|
/* object fields like ob_type are uninitialized! */ |
|
|
/* object fields like ob_type are uninitialized! */ |
|
|
return test_pyobject_is_freed("check_pyobject_uninitialized_is_freed", op); |
|
|
return test_pyobject_is_freed("check_pyobject_uninitialized_is_freed", op); |
|
|
} |
|
|
} |
|
|
@ -4636,7 +4637,7 @@ check_pyobject_forbidden_bytes_is_freed(PyObject *self, PyObject *Py_UNUSED(args |
|
|
return NULL; |
|
|
return NULL; |
|
|
} |
|
|
} |
|
|
/* Initialize reference count to avoid early crash in ceval or GC */ |
|
|
/* Initialize reference count to avoid early crash in ceval or GC */ |
|
|
Py_REFCNT(op) = 1; |
|
|
|
|
|
|
|
|
Py_SET_REFCNT(op, 1); |
|
|
/* ob_type field is after the memory block: part of "forbidden bytes" |
|
|
/* ob_type field is after the memory block: part of "forbidden bytes" |
|
|
when using debug hooks on memory allocators! */ |
|
|
when using debug hooks on memory allocators! */ |
|
|
return test_pyobject_is_freed("check_pyobject_forbidden_bytes_is_freed", op); |
|
|
return test_pyobject_is_freed("check_pyobject_forbidden_bytes_is_freed", op); |
|
|
@ -4652,7 +4653,7 @@ check_pyobject_freed_is_freed(PyObject *self, PyObject *Py_UNUSED(args)) |
|
|
} |
|
|
} |
|
|
Py_TYPE(op)->tp_dealloc(op); |
|
|
Py_TYPE(op)->tp_dealloc(op); |
|
|
/* Reset reference count to avoid early crash in ceval or GC */ |
|
|
/* Reset reference count to avoid early crash in ceval or GC */ |
|
|
Py_REFCNT(op) = 1; |
|
|
|
|
|
|
|
|
Py_SET_REFCNT(op, 1); |
|
|
/* object memory is freed! */ |
|
|
/* object memory is freed! */ |
|
|
return test_pyobject_is_freed("check_pyobject_freed_is_freed", op); |
|
|
return test_pyobject_is_freed("check_pyobject_freed_is_freed", op); |
|
|
} |
|
|
} |
|
|
@ -5134,7 +5135,7 @@ negative_refcount(PyObject *self, PyObject *Py_UNUSED(args)) |
|
|
} |
|
|
} |
|
|
assert(Py_REFCNT(obj) == 1); |
|
|
assert(Py_REFCNT(obj) == 1); |
|
|
|
|
|
|
|
|
Py_REFCNT(obj) = 0; |
|
|
|
|
|
|
|
|
Py_SET_REFCNT(obj, 0); |
|
|
/* Py_DECREF() must call _Py_NegativeRefcount() and abort Python */ |
|
|
/* Py_DECREF() must call _Py_NegativeRefcount() and abort Python */ |
|
|
Py_DECREF(obj); |
|
|
Py_DECREF(obj); |
|
|
|
|
|
|
|
|
|