[issue31338] Use abort() for code we never expect to hit

Barry A. Warsaw report at bugs.python.org
Tue Sep 5 19:30:45 EDT 2017


Barry A. Warsaw added the comment:

On Sep 5, 2017, at 16:07, STINNER Victor <report at bugs.python.org> wrote:
> 
> STINNER Victor added the comment:
> 
>> Neither gcc (macOS, Ubuntu), nor clang (Ubuntu) complain.
> 
> Ok, cool. In that case, go ahead.

I checked with @steve.dower and I think abort() will work on MSVC too.  He did have the idea to #define it to `Py_FatalError(“some message”); abort();` but since the former calls the latter we could get warnings that the second abort() isn’t reachable.

I say we start with abort() as the expansion and go from there.  Since it’s a macro it’s easy to redefine if you want to crank up debugging, add a breakpoint, add __LINE__ and __FILE__ or need something special for some particular compiler.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31338>
_______________________________________


More information about the Python-bugs-list mailing list