diff -r abbc9ae0a384 Include/unicodeobject.h --- a/Include/unicodeobject.h Wed Mar 13 10:45:33 2013 -0700 +++ b/Include/unicodeobject.h Wed Mar 13 19:32:43 2013 +0100 @@ -2212,14 +2212,19 @@ PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy( PyObject *unicode ); -#endif /* Py_LIMITED_API */ - -#if defined(Py_DEBUG) && !defined(Py_LIMITED_API) + +#if defined(Py_DEBUG) PyAPI_FUNC(int) _PyUnicode_CheckConsistency( PyObject *op, int check_content); +#elif !defined(NDEBUG) +/* _PyUnicode_CheckConsistency is used in assert statements, so it needs to + be defined whenever NDEBUG isn't set, even when Py_DEBUG isn't set. */ +#define _PyUnicode_CheckConsistency(op, check_content) PyUnicode_Check(op) #endif +#endif /* Py_LIMITED_API */ + /* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/ PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*); /* Clear all static strings. */ diff -r abbc9ae0a384 Objects/obmalloc.c --- a/Objects/obmalloc.c Wed Mar 13 10:45:33 2013 -0700 +++ b/Objects/obmalloc.c Wed Mar 13 19:32:43 2013 +0100 @@ -1869,14 +1869,16 @@ if (p->ref.count == 0) { /* currently unused */ +#ifdef PYMALLOC_DEBUG assert(pool_is_in_list(p, arenas[i].freepools)); +#endif continue; } ++numpools[sz]; numblocks[sz] += p->ref.count; freeblocks = NUMBLOCKS(sz) - p->ref.count; numfreeblocks[sz] += freeblocks; -#ifdef Py_DEBUG +#ifdef PYMALLOC_DEBUG if (freeblocks > 0) assert(pool_is_in_list(p, usedpools[sz + sz])); #endif