STINNER Victor <vstin...@python.org> added the comment:
> I think that adding macros makes readability worse. See the attached PRs, I can remove multiple layers of parenthesis in macros by using CAST macros. > ``` > PyObject *func = ...; > int flags = PyCFunction_GET_FLAGS(func); > ``` > > is dangerous. Right. PEP 670 proposes to remove the cast, but only in the limited C API version 3.11 or newer. Sadly, I don't think that we can remove the cast in the general Python C API, it would simply add too many compiler warnings in existing C extensions which previously built without warnings. (See also PEP 670 discussions on python-dev). Currently, PyCFunction_GET_FLAGS() doesn't check its argument. The macro documentation is quite explicit about it: /* Macros for direct access to these values. Type checks are *not* done, so use with care. */ My GH-32190 PR adds a check in debug mode. So using PyCFunction_GET_FLAGS() in debug mode is safer with this PR. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue47164> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com