using C's "assert" macro in extension code

Gerhard Häring gh at ghaering.de
Wed Mar 26 19:45:50 CET 2003


* Maciej Kalisiak <mac at die.spammer.die.dgp.toronto.edu> [2003-03-26 18:28 +0000]:
> I tend to litter my experimental code with a healthy dose of "assert"
> statements, and writing Python extensions is no exception.  I've recently
> noticed that my asserts are not being executed, which led me to realize that
> the Makefile created by "make -f Makefile.pre.in boot" always uses "-DNDEBUG",
> which disables the assert macro. [...]

NDEBUG is only defined in release builds of Python (and also extension
modules, via distutils). If you create a debug build of Python, NDEBUG
won't be defined and your asserts will work again.

HTH,

Gerhard
-- 
mail:   gh at ghaering.de
web:    http://ghaering.de/





More information about the Python-list mailing list