/* If it's initialized memory, op must be in or out of
* the list unambiguously.
*/
- assert((op->_ob_prev == NULL) == (op->_ob_next == NULL));
+ _PyObject_ASSERT(op, (op->_ob_prev == NULL) == (op->_ob_next == NULL));
}
#endif
if (force || op->_ob_prev == NULL) {
/* Undo the temporary resurrection; can't use DECREF here, it would
* cause a recursive call.
*/
- assert(self->ob_refcnt > 0);
+ _PyObject_ASSERT_WITH_MSG(self,
+ self->ob_refcnt > 0,
+ "refcount is too small");
if (--self->ob_refcnt == 0)
return 0; /* this is the normal path out */
_Py_NewReference(self);
self->ob_refcnt = refcnt;
- assert(!PyType_IS_GC(Py_TYPE(self)) || _PyObject_GC_IS_TRACKED(self));
+ _PyObject_ASSERT(self,
+ (!PyType_IS_GC(Py_TYPE(self))
+ || _PyObject_GC_IS_TRACKED(self)));
/* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
* we need to undo that. */
_Py_DEC_REFTOTAL;
return err;
}
Py_DECREF(name);
- assert(name->ob_refcnt >= 1);
+ _PyObject_ASSERT(name, name->ob_refcnt >= 1);
if (tp->tp_getattr == NULL && tp->tp_getattro == NULL)
PyErr_Format(PyExc_TypeError,
"'%.100s' object has no attributes "
size = _PyObject_VAR_SIZE(tp, tsize);
dictoffset += (long)size;
- assert(dictoffset > 0);
- assert(dictoffset % SIZEOF_VOID_P == 0);
+ _PyObject_ASSERT(obj, dictoffset > 0);
+ _PyObject_ASSERT(obj, dictoffset % SIZEOF_VOID_P == 0);
}
return (PyObject **) ((char *)obj + dictoffset);
}
if (tsize < 0)
tsize = -tsize;
size = _PyObject_VAR_SIZE(tp, tsize);
- assert(size <= PY_SSIZE_T_MAX);
+ _PyObject_ASSERT(obj, size <= PY_SSIZE_T_MAX);
dictoffset += (Py_ssize_t)size;
- assert(dictoffset > 0);
- assert(dictoffset % SIZEOF_VOID_P == 0);
+ _PyObject_ASSERT(obj, dictoffset > 0);
+ _PyObject_ASSERT(obj, dictoffset % SIZEOF_VOID_P == 0);
}
dictptr = (PyObject **) ((char *)obj + dictoffset);
dict = *dictptr;
PyObject *result, *sorted;
PyObject *dirfunc = _PyObject_LookupSpecial(obj, &PyId___dir__);
- assert(obj);
+ assert(obj != NULL);
if (dirfunc == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(PyExc_TypeError, "object does not provide __dir__");
void
_PyTrash_deposit_object(PyObject *op)
{
- assert(PyObject_IS_GC(op));
- assert(!_PyObject_GC_IS_TRACKED(op));
- assert(op->ob_refcnt == 0);
+ _PyObject_ASSERT(op, PyObject_IS_GC(op));
+ _PyObject_ASSERT(op, !_PyObject_GC_IS_TRACKED(op));
+ _PyObject_ASSERT(op, op->ob_refcnt == 0);
_PyGCHead_SET_PREV(_Py_AS_GC(op), _PyRuntime.gc.trash_delete_later);
_PyRuntime.gc.trash_delete_later = op;
}
_PyTrash_thread_deposit_object(PyObject *op)
{
PyThreadState *tstate = PyThreadState_GET();
- assert(PyObject_IS_GC(op));
- assert(!_PyObject_GC_IS_TRACKED(op));
- assert(op->ob_refcnt == 0);
+ _PyObject_ASSERT(op, PyObject_IS_GC(op));
+ _PyObject_ASSERT(op, !_PyObject_GC_IS_TRACKED(op));
+ _PyObject_ASSERT(op, op->ob_refcnt == 0);
_PyGCHead_SET_PREV(_Py_AS_GC(op), tstate->trash_delete_later);
tstate->trash_delete_later = op;
}
* assorted non-release builds calling Py_DECREF again ends
* up distorting allocation statistics.
*/
- assert(op->ob_refcnt == 0);
+ _PyObject_ASSERT(op, op->ob_refcnt == 0);
++_PyRuntime.gc.trash_delete_nesting;
(*dealloc)(op);
--_PyRuntime.gc.trash_delete_nesting;
* assorted non-release builds calling Py_DECREF again ends
* up distorting allocation statistics.
*/
- assert(op->ob_refcnt == 0);
+ _PyObject_ASSERT(op, op->ob_refcnt == 0);
(*dealloc)(op);
assert(tstate->trash_delete_nesting == 1);
}