STINNER Victor <vstin...@python.org> added the comment:

I'm replacing macros with static inline functions to avoid issues like this one 
(ex: bpo-35059). Are you interested to convert the PyObject_TypeCheck() macro 
to a static inline function?

"""
There is a lot of macros like:
    #define PyObject_TypeCheck(ob, tp) \
    (Py_IS_TYPE(ob, tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))
These work fine until an argument happen to contain a comma.
"""

This macro also has a common bug of macros: if one argument has a side effect, 
it is executed twice! For example, if an argument is a function call, the 
function is called twice.

See:

* https://gcc.gnu.org/onlinedocs/cpp/Macro-Pitfalls.html
* https://vstinner.github.io/split-include-directory-python38.html "Convert 
macros to static inline functions"

----------

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

Reply via email to