Make a non-Py_DEBUG, asserts-enabled build of CPython possible. This means
making sure helper functions are defined when NDEBUG is not defined, not
just when Py_DEBUG is defined.
Also fix a division-by-zero in obmalloc.c that went unnoticed because in Py_DEBUG mode, elsize is never zero.
PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
PyObject *op,
int check_content);
+#elif !defined(NDEBUG)
+/* For asserts that call _PyUnicode_CheckConsistency(), which would
+ * otherwise be a problem when building with asserts but without Py_DEBUG. */
+#define _PyUnicode_CheckConsistency(op, check_content) PyUnicode_Check(op)
#endif
#ifndef Py_LIMITED_API
/* #define DEBUG_PYDICT */
-#ifdef Py_DEBUG
+#ifndef NDEBUG
static int
_PyDict_CheckConsistency(PyDictObject *mp)
{
_Py_AllocatedBlocks++;
+ if (nelem == 0 || elsize == 0)
+ goto redirect;
+
assert(nelem <= PY_SSIZE_T_MAX / elsize);
nbytes = nelem * elsize;
goto redirect;
#endif
- if (nelem == 0 || elsize == 0)
- goto redirect;
-
if ((nbytes - 1) < SMALL_REQUEST_THRESHOLD) {
LOCK();
/*
return NULL;
}
-#ifdef Py_DEBUG
+#ifndef NDEBUG
static int
_PyType_CheckConsistency(PyTypeObject *type)
{