[BUG] Use of ob_shash is deprecated on 3.11
See original GitHub issueDescribe the bug A clear and concise description of what the bug is.
Using PyStringObject->ob_shash
is deprecated in Python 3.11 and emits a warning. NumPy fails the builds on warnings.
To Reproduce We are seeing this in NumPy when building for Python 3.11. Expected behavior A clear and concise description of what you expected to happen.
Environment (please complete the following information):
- OS: [e.g. Linux, Windows, macOS]
- Python version [e.g. 3.8.4]
- Cython version [e.g. 0.29.18]
All OSs, Python 3.11alpha, Cython HEAD and 0.29.28
Additional context Add any other context about the problem here.
Cython could decide to tell downstream projects to ignore the deprecation warning, which would allow the problem to be pushed off for 2 years.
Another alternative is to avoid the fast path that uses internals. Would it be a significant slowdown to skip this for Python>=3.11? https://github.com/cython/cython/blob/c79ae55a7440459dae7667699284a72b09e89185/Cython/Utility/StringTools.c#L369-L379
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
Given the
CYTHON_USE_UNICODE_INTERNALS
guard, this is probably a relict of Py2 times, when Py2str
was more important than it is today. I’d just mark the fast path as Py<3.11 only and phase it out that way. It shouldn’t make that much of a difference, except for longer byte strings (with long identical prefixes).Thanks 🚀