-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In C++, Python 3.11 C API introduces new compiler warnings/errors #92135
Labels
type-bug
An unexpected behavior, bug, or error
Comments
Documentation: |
vstinner
added a commit
that referenced
this issue
May 2, 2022
Fix C++ compiler warnings on cast macros, like _PyObject_CAST(), when casting a constant expression to a non constant type: use const_cast<> in C++. * In C++, Py_SAFE_DOWNCAST() now uses static_cast<> rather than reinterpret_cast<>. * Add tests to the _testcppext C++ extension. * test_cppext no longer captures stdout in verbose mode.
Fixed by #92138 |
vstinner
added a commit
that referenced
this issue
May 3, 2022
Rename also _Py_static_cast() to _Py_STATIC_CAST().
tiran
added a commit
to tiran/cpython
that referenced
this issue
May 5, 2022
tiran
added a commit
that referenced
this issue
May 5, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To fix C++ compiler warnings about "old-style casts", I recently modified the Python C API to use C++
reinterpret_cast<>
andstatic_cast<>
: #91959Previously, "old-style cast" like
(PyObject*)expr
didn't emit a compiler warning ifexpr
wasconst
. 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.
The text was updated successfully, but these errors were encountered: