[issue43181] Python macros don’t shield arguments

STINNER Victor report at bugs.python.org
Thu Mar 11 10:15:20 EST 2021


STINNER Victor <vstinner at python.org> added the comment:

> Yet... the first argument is still unshielded, passed to a macro that expects one single macro argument.

Are you talking about the current code in the master branch or the 3.9 branch? If you are talking about the _PyObject_CAST(ob) call, would you mind to elaborate how it is an issue? The code in master LGTM.

> That’s not a regression, it wasn’t shielded in 3.8 either, but why not just parenthesise each macro argument that denotes an expression (as opposed to e.g. name)?

In the master branch, Include/ and its subdirectories contains 158 .h files for a total of 20K lines of C code. It's not easy to check all files. If you spotted bugs, would you mind to give examples, or a way to automatically detect bugs?

As I wrote previously, I dislike macros. If someone is changed, I would prefer to convert the function into a static inline function which doesn't have macros pitfalls.

----------

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


More information about the Python-bugs-list mailing list