[New-bugs-announce] [issue35199] Convert PyTuple_GET_ITEM() macro to a function call with additional checks in debug mode

STINNER Victor report at bugs.python.org
Fri Nov 9 10:32:02 EST 2018


New submission from STINNER Victor <vstinner at redhat.com>:

Currently, even when Python is compiled in debug mode, PyTuple_GET_ITEM() doesn't check that the first argument is a tuple objet and that the second argument is valid index. It can lead to a crash and Python doesn't help debugging.

I propose to convert the macro to a function call and use regular assertions to abort Python if the C API is misused.

I propose to use a function call rather than abusing the preprocessor syntax like (assert(...),expr) syntax used in unicodeobject.h, because I the preprocessor causes complex bugs (difficult to understand and to fix/work around) and because later I would like to experiment to be able to compile C extensions to always use function calls, but get a different implementation depending on the "Python runtime".

I elaborated this idea on this website:

* https://pythoncapi.readthedocs.io/runtimes.html#debug-build
* https://pythoncapi.readthedocs.io/

I am working on an implementation.

----------
components: Interpreter Core
messages: 329523
nosy: vstinner
priority: normal
severity: normal
status: open
title: Convert PyTuple_GET_ITEM() macro to a function call with additional checks in debug mode
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35199>
_______________________________________


More information about the New-bugs-announce mailing list