From 60252260070137dd75f09d99a50c5dc624dea439 Mon Sep 17 00:00:00 2001 From: Elvis Pranskevichus Date: Wed, 22 Apr 2020 17:58:50 -0700 Subject: Define NDEBUG actively `NDEBUG` is not defined by the standard library or the compiler by default, so make sure it's defined when building non-debug builds. --- immutables/_map.c | 14 +++++++------- setup.py | 9 ++++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/immutables/_map.c b/immutables/_map.c index 19ce760..167385a 100644 --- a/immutables/_map.c +++ b/immutables/_map.c @@ -393,7 +393,7 @@ static MapObject * map_update(uint64_t mutid, MapObject *o, PyObject *src); -#ifndef NDEBUG +#if !defined(NDEBUG) static void _map_node_array_validate(void *o) { @@ -1110,7 +1110,7 @@ map_node_bitmap_without(MapNode_Bitmap *self, } } -#ifndef NDEBUG +#if !defined(NDEBUG) /* Ensure that Collision.without implementation converts to Bitmap nodes itself. */ @@ -2009,7 +2009,7 @@ map_node_array_without(MapNode_Array *self, } else { -#ifndef NDEBUG +#if !defined(NDEBUG) if (IS_COLLISION_NODE(node)) { assert( (map_node_collision_count( @@ -2303,7 +2303,7 @@ map_iterator_bitmap_next(MapIteratorState *iter, Py_ssize_t pos = iter->i_pos[level]; if (pos + 1 >= Py_SIZE(node)) { -#ifndef NDEBUG +#if !defined(NDEBUG) assert(iter->i_level >= 0); iter->i_nodes[iter->i_level] = NULL; #endif @@ -2340,7 +2340,7 @@ map_iterator_collision_next(MapIteratorState *iter, Py_ssize_t pos = iter->i_pos[level]; if (pos + 1 >= Py_SIZE(node)) { -#ifndef NDEBUG +#if !defined(NDEBUG) assert(iter->i_level >= 0); iter->i_nodes[iter->i_level] = NULL; #endif @@ -2364,7 +2364,7 @@ map_iterator_array_next(MapIteratorState *iter, Py_ssize_t pos = iter->i_pos[level]; if (pos >= HAMT_ARRAY_NODE_SIZE) { -#ifndef NDEBUG +#if !defined(NDEBUG) assert(iter->i_level >= 0); iter->i_nodes[iter->i_level] = NULL; #endif @@ -2386,7 +2386,7 @@ map_iterator_array_next(MapIteratorState *iter, } } -#ifndef NDEBUG +#if !defined(NDEBUG) assert(iter->i_level >= 0); iter->i_nodes[iter->i_level] = NULL; #endif diff --git a/setup.py b/setup.py index 3749742..a30fc5d 100644 --- a/setup.py +++ b/setup.py @@ -18,20 +18,23 @@ with open(os.path.join( break else: raise RuntimeError( - 'unable to read the version from immutables/__init__.py') + 'unable to read the version from immutables/_version.py') if platform.python_implementation() == 'CPython': if os.environ.get("DEBUG_IMMUTABLES") == '1': - undef_macros = ["NDEBUG"] + define_macros = [] + undef_macros = ['NDEBUG'] else: - undef_macros = None + define_macros = [('NDEBUG', '1')] + undef_macros = [] ext_modules = [ setuptools.Extension( "immutables._map", ["immutables/_map.c"], extra_compile_args=CFLAGS, + define_macros=define_macros, undef_macros=undef_macros) ] else: -- cgit v1.2.3