bpo-29941: Assert fixes (#886) (#955) · python/cpython@90e3518 (original) (raw)
3 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2309,6 +2309,10 @@ PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy( | ||
2309 | 2309 | PyAPI_FUNC(int) _PyUnicode_CheckConsistency( |
2310 | 2310 | PyObject *op, |
2311 | 2311 | int check_content); |
2312 | +#elif !defined(NDEBUG) | |
2313 | +/* For asserts that call _PyUnicode_CheckConsistency(), which would | |
2314 | + * otherwise be a problem when building with asserts but without Py_DEBUG. */ | |
2315 | +#define _PyUnicode_CheckConsistency(op, check_content) PyUnicode_Check(op) | |
2312 | 2316 | #endif |
2313 | 2317 | |
2314 | 2318 | #ifndef Py_LIMITED_API |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -436,7 +436,7 @@ static PyObject *empty_values[1] = { NULL }; | ||
436 | 436 | /* #define DEBUG_PYDICT */ |
437 | 437 | |
438 | 438 | |
439 | -#ifdef Py_DEBUG | |
439 | +#ifndef NDEBUG | |
440 | 440 | static int |
441 | 441 | _PyDict_CheckConsistency(PyDictObject *mp) |
442 | 442 | { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1227,7 +1227,7 @@ _PyObject_Alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize) | ||
1227 | 1227 | |
1228 | 1228 | _Py_AllocatedBlocks++; |
1229 | 1229 | |
1230 | -assert(nelem <= PY_SSIZE_T_MAX / elsize); | |
1230 | +assert(elsize == 0 | | |
1231 | 1231 | nbytes = nelem * elsize; |
1232 | 1232 | |
1233 | 1233 | #ifdef WITH_VALGRIND |