Tim Peters added the comment:

So there's more than one issue here.

First, should asserts be supported in the absence of Py_DEBUG?  It seems, so 
far, everyone agrees they should be.

Second, ...?  I'm really not following your argument.  It _appears_ to be 
something along the lines that code "shouldn't be" checking for 
PyErr_Occurred() at all ... because "nothing goes 'more wrong' when the assert 
is not there".  Maybe, maybe not.  For example, if a C function _assumes_ no 
exception is pending at entry, then it could try some speculative code and 
deliberately PyErr_Clear() if PyErr_Occurred() is true after - and end up 
erasing all knowledge of that an exception _was_ in fact pending (upon function 
entry).  An assert at the start prevents such an error when asserts are 
enabled.  Violations of preconditions can have bad consequences.

But whatever the second argument is, it seems independent of whether asserts 
should be supported in the absence of Py_DEBUG.

For the rest, I just don't think "internal to CPython" versus "external to 
CPython".  That's a matter of how things happen to be packaged today.  I do 
think "written in C" versus "not written in C".  That's the level asserts live 
in.  Any C code (internal or external) mucking with the Python C API has to 
adhere to a mountain of rules, and asserts are a lightweight way to help check 
for compliance in cases where it's thought to be "too expensive" to do even 
cheap unconditional checks all the time.  Of course asserts are also useful for 
verifying invariants and postconditions, but I wouldn't want to rule out using 
them to verify preconditions too.

In short, I'd like to see a patch limited to the obvious win:  whatever changes 
are needed to support asserts in the absence of Py_DEBUG.  Anything beyond that 
is "a crusade" ;-)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29941>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to