Skip to content

In C++, Python 3.11 C API introduces new compiler warnings/errors #92135

Closed
@vstinner

Description

@vstinner

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions