Skip to content

Commit 6025226

Browse files
committed
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.
1 parent d107c3e commit 6025226

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

immutables/_map.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ static MapObject *
393393
map_update(uint64_t mutid, MapObject *o, PyObject *src);
394394

395395

396-
#ifndef NDEBUG
396+
#if !defined(NDEBUG)
397397
static void
398398
_map_node_array_validate(void *o)
399399
{
@@ -1110,7 +1110,7 @@ map_node_bitmap_without(MapNode_Bitmap *self,
11101110
}
11111111
}
11121112

1113-
#ifndef NDEBUG
1113+
#if !defined(NDEBUG)
11141114
/* Ensure that Collision.without implementation
11151115
converts to Bitmap nodes itself.
11161116
*/
@@ -2009,7 +2009,7 @@ map_node_array_without(MapNode_Array *self,
20092009
}
20102010
else {
20112011

2012-
#ifndef NDEBUG
2012+
#if !defined(NDEBUG)
20132013
if (IS_COLLISION_NODE(node)) {
20142014
assert(
20152015
(map_node_collision_count(
@@ -2303,7 +2303,7 @@ map_iterator_bitmap_next(MapIteratorState *iter,
23032303
Py_ssize_t pos = iter->i_pos[level];
23042304

23052305
if (pos + 1 >= Py_SIZE(node)) {
2306-
#ifndef NDEBUG
2306+
#if !defined(NDEBUG)
23072307
assert(iter->i_level >= 0);
23082308
iter->i_nodes[iter->i_level] = NULL;
23092309
#endif
@@ -2340,7 +2340,7 @@ map_iterator_collision_next(MapIteratorState *iter,
23402340
Py_ssize_t pos = iter->i_pos[level];
23412341

23422342
if (pos + 1 >= Py_SIZE(node)) {
2343-
#ifndef NDEBUG
2343+
#if !defined(NDEBUG)
23442344
assert(iter->i_level >= 0);
23452345
iter->i_nodes[iter->i_level] = NULL;
23462346
#endif
@@ -2364,7 +2364,7 @@ map_iterator_array_next(MapIteratorState *iter,
23642364
Py_ssize_t pos = iter->i_pos[level];
23652365

23662366
if (pos >= HAMT_ARRAY_NODE_SIZE) {
2367-
#ifndef NDEBUG
2367+
#if !defined(NDEBUG)
23682368
assert(iter->i_level >= 0);
23692369
iter->i_nodes[iter->i_level] = NULL;
23702370
#endif
@@ -2386,7 +2386,7 @@ map_iterator_array_next(MapIteratorState *iter,
23862386
}
23872387
}
23882388

2389-
#ifndef NDEBUG
2389+
#if !defined(NDEBUG)
23902390
assert(iter->i_level >= 0);
23912391
iter->i_nodes[iter->i_level] = NULL;
23922392
#endif

setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,23 @@
1818
break
1919
else:
2020
raise RuntimeError(
21-
'unable to read the version from immutables/__init__.py')
21+
'unable to read the version from immutables/_version.py')
2222

2323

2424
if platform.python_implementation() == 'CPython':
2525
if os.environ.get("DEBUG_IMMUTABLES") == '1':
26-
undef_macros = ["NDEBUG"]
26+
define_macros = []
27+
undef_macros = ['NDEBUG']
2728
else:
28-
undef_macros = None
29+
define_macros = [('NDEBUG', '1')]
30+
undef_macros = []
2931

3032
ext_modules = [
3133
setuptools.Extension(
3234
"immutables._map",
3335
["immutables/_map.c"],
3436
extra_compile_args=CFLAGS,
37+
define_macros=define_macros,
3538
undef_macros=undef_macros)
3639
]
3740
else:

0 commit comments

Comments
 (0)