-
-
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
PyUnicode_READ() fails to build on C++: _Py_CAST() used with a constant type (const void*) #92800
Comments
This issue is scattered across a couple of places (which may be my fault) here is an index of the relevant links:
|
The C++ project scipy fails to build with:
Oh right, that's my fault, _Py_CAST() cannot be used with a const type. _Py_CAST() comment:
|
Would you be able to test if #92872 fix scipy? |
I can confirm that scipy (and a large fraction of the pydata stack) build with #92872 . |
Fixed by #92872 : thanks for the bug report! |
Thus fixing PyUnicode_READ in C++. Fixes python/cpython#92800 I've created a C++ helper struct definition to work out the type with constant added (it's OK to add const to a constant type in typedefs in C++).
Bug report
The new
_Py_CAST
macro (https://github.com/python/cpython/pull/91959/files, and other commits) designed to reduce C++ warnings adds a fairly significant restriction that wasn't there beforecpython/Include/pyport.h
Lines 25 to 26 in 9f68dab
The PyUnicode_READ macro casts to a const pointer
cpython/Include/cpython/unicodeobject.h
Lines 341 to 343 in 9f68dab
This is currently reported to be breaking Cython (cython/cython#4790).
I'd propose a fix which removes the const requirement:
on C++11 you could use the standard library
std::add_cast
instead, at the cost of an extra include. However it isn't available on c++03.I realise this adds an extra struct
_Py_add_const
to the namespace. I'm not sure if that's desired, or how it should be named. If that's acceptable I'm happy to submit a PR for this.@vstinner
Your environment
Current 3.11 branch
The text was updated successfully, but these errors were encountered: