8000 Revert "bpo-29941: Assert fixes (#886)" · python/cpython@27058ed · GitHub
[go: up one dir, main page]

Skip to content

Commit 27058ed

Browse files
authored
Revert "bpo-29941: Assert fixes (#886)"
This reverts commit a00c3fd.
1 parent a00c3fd commit 27058ed

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

Include/unicodeobject.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,10 +2313,6 @@ PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy(
23132313
PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
23142314
PyObject *op,
23152315
int check_content);
2316-
#elif !defined(NDEBUG)
2317-
/* For asserts that call _PyUnicode_CheckConsistency(), which would
2318-
* otherwise be a problem when building with asserts but without Py_DEBUG. */
2319-
#define _PyUnicode_CheckConsistency(op, check_content) PyUnicode_Check(op)
23202316
#endif
23212317

23222318
#ifndef Py_LIMITED_API

Objects/dictobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ static PyObject *empty_values[1] = { NULL };
437437
/* #define DEBUG_PYDICT */
438438

439439

440-
#ifndef NDEBUG
440+
#ifdef Py_DEBUG
441441
static int
442442
_PyDict_CheckConsistency(PyDictObject *mp)
443443
{

Objects/obmalloc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,9 +1227,6 @@ _PyObject_Alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize)
12271227

12281228
_Py_AllocatedBlocks++;
12291229

1230-
if (nelem == 0 || elsize == 0)
1231-
goto redirect;
1232-
12331230
assert(nelem <= PY_SSIZE_T_MAX / elsize);
12341231
nbytes = nelem * elsize;
12351232

@@ -1240,6 +1237,9 @@ _PyObject_Alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize)
12401237
goto redirect;
12411238
#endif
12421239

1240+
if (nelem == 0 || elsize == 0)
1241+
goto redirect;
1242+
12431243
if ((nbytes - 1) < SMALL_REQUEST_THRESHOLD) {
12441244
LOCK();
12451245
/*

Objects/typeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ skip_signature(const char *doc)
128128
return NULL;
129129
}
130130

131-
#ifndef NDEBUG
131+
#ifdef Py_DEBUG
132132
static int
133133
_PyType_CheckConsistency(PyTypeObject *type)
134134
{

0 commit comments

Comments
 (0)
0