PyArray_PythonPyIntFromInt existed to not change behavior of existing code that used the "i" format in Python.
But along the way, Python fixed their things, the conversion now uses __index__ as it should and rejects all non-integers (not just floats explictly).
We missed that and while we used to be ahead of the curve we are now behind here. So what we should do is:
- Try the
__index__ style conversion. (this is a tiny bug fix as well)
- If that fails, try current code with a warning.
It would be nice to audit if there are remaining "i" uses that matters, because if there aren't we can be clearer about when the warning was introduced (i.e. we won't use it for more functions).
Additionally, it may be nice to do a check whether all integers are used in places where NumPy may just want to directly transition to our integer conversion helpers. These differ in that NumPy sometimes rejects booleans.
(This doesn't matter much either way, the bool rejecting matters mostly in places that are slightly indexing related.)
PyArray_PythonPyIntFromIntexisted to not change behavior of existing code that used the"i"format in Python.But along the way, Python fixed their things, the conversion now uses
__index__as it should and rejects all non-integers (not just floats explictly).We missed that and while we used to be ahead of the curve we are now behind here. So what we should do is:
__index__style conversion. (this is a tiny bug fix as well)It would be nice to audit if there are remaining
"i"uses that matters, because if there aren't we can be clearer about when the warning was introduced (i.e. we won't use it for more functions).Additionally, it may be nice to do a check whether all integers are used in places where NumPy may just want to directly transition to our integer conversion helpers. These differ in that NumPy sometimes rejects booleans.
(This doesn't matter much either way, the bool rejecting matters mostly in places that are slightly indexing related.)