using C's "assert" macro in extension code

Maciej Kalisiak mac at die.spammer.die.dgp.toronto.edu
Wed Mar 26 13:28:26 EST 2003


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.  Does this mean that using C's asserts in
extension code is frowned upon?  I know it's not as clean as properly handling
the problem and letting the Python interpreter know about it, but sometimes
when writing one-off code you don't really want/need to bother being robust.
If asserts are undesirable for some reason, what is the accepted way of doing
the equivalent?




More information about the Python-list mailing list