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
PyTuple_SET_ITEM fails to compile in C++ source #93442
Comments
What is the result type of terms.get()? Can you write a short C++ code reproducing the issue? I guess that the cast which fails is |
My understanding is that in C https://stackoverflow.com/questions/176989/do-you-use-null-or-0-zero-for-pointers-in-c For the kiwi source code, using
My guess is that the macro for PyTuple_GET_SIZE does not treat 0/NULL correctly but I don't know how you would fix it. |
In C++, nullptr should be used to pass a "null pointer" (0), no? Well, Python should accept 0 as |
The issue can be reproduced by running test_cppext with this change:
|
My guess is that the |
It looks like
and similar macros? Maybe the |
The following overloads seem to be needed to cover all cases
|
I can confirm this change makes |
@serge-sans-paille would you like to submit the PR for this issue? cc @nascheme @vstinner |
Add C++ overloads for _Py_CAST_impl() to handle 0/NULL. This will allow C++ extensions that pass 0 or NULL to macros using _Py_CAST() to continue to compile. Without this, you get an error like: invalid ‘static_cast’ from type ‘int’ to type ‘_object*’ The modern way to use a NULL value in C++ is to use nullptr. However, we want to not break extensions that do things the old way. Co-authored-by: serge-sans-paille
…nGH-93500) Add C++ overloads for _Py_CAST_impl() to handle 0/NULL. This will allow C++ extensions that pass 0 or NULL to macros using _Py_CAST() to continue to compile. Without this, you get an error like: invalid ‘static_cast’ from type ‘int’ to type ‘_object*’ The modern way to use a NULL value in C++ is to use nullptr. However, we want to not break extensions that do things the old way. Co-authored-by: serge-sans-paille (cherry picked from commit 8bcc3fa) Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
…h-93507) Add C++ overloads for _Py_CAST_impl() to handle 0/NULL. This will allow C++ extensions that pass 0 or NULL to macros using _Py_CAST() to continue to compile. Without this, you get an error like: invalid ‘static_cast’ from type ‘int’ to type ‘_object*’ The modern way to use a NULL value in C++ is to use nullptr. However, we want to not break extensions that do things the old way. Co-authored-by: serge-sans-paille (cherry picked from commit 8bcc3fa) Co-authored-by: Neil Schemenauer <nas-github@arctrix.com> Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
(cherry picked from commit 713eb18) Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
The kiwisolver extension doesn't compile with beta 3. The error is:
This seems to be an issue with the new inline functions for things that used to be macros. E.g. PyTuple_SET_ITEM. The C++ code triggering the issue is:
Replacing the macro with the function version seems to allow the extension to compile.
This seems related to #92898
The text was updated successfully, but these errors were encountered: