Closed
Description
To fix C++ compiler warnings about "old-style casts", I recently modified the Python C API to use C++ reinterpret_cast<>
and static_cast<>
: #91959
Previously, "old-style cast" like (PyObject*)expr
didn't emit a compiler warning if expr
was const
. Now with the new cast, C++ compilers emit warnings: see #91959 (comment)
const_cast<>
can be used to fix this issue.
Note: PEP 670 was accepted with the condition: converting macros to functions must not introduce new compiler warnings (so no new compile errors neither). But most functions modified in Python 3.11 (to use C++ casts) were already static inline functions in Python 3.10.