Message416358
> 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. |
|
Date |
User |
Action |
Args |
2022-03-30 14:00:23 | vstinner | set | recipients:
+ vstinner, Mark.Shannon, kj |
2022-03-30 14:00:23 | vstinner | set | messageid: <1648648823.85.0.831736930555.issue47164@roundup.psfhosted.org> |
2022-03-30 14:00:23 | vstinner | link | issue47164 messages |
2022-03-30 14:00:23 | vstinner | create | |
|