This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients Thomas Wouters, gregory.p.smith, serhiy.storchaka, tim.peters, twouters, vstinner
Date 2017-03-30.18:07:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1490897250.48.0.913581258435.issue29941@psf.upfronthosting.co.za>
In-reply-to
Content
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" ;-)
History
Date User Action Args
2017-03-30 18:07:30tim.peterssetrecipients: + tim.peters, twouters, gregory.p.smith, vstinner, serhiy.storchaka, Thomas Wouters
2017-03-30 18:07:30tim.peterssetmessageid: <1490897250.48.0.913581258435.issue29941@psf.upfronthosting.co.za>
2017-03-30 18:07:30tim.peterslinkissue29941 messages
2017-03-30 18:07:30tim.peterscreate