STINNER Victor <vstin...@python.org> added the comment:

> DeprecationWarning: In future, it will be an error for 'np.bool_' scalars to 
> be interpreted as an index

That sounds like an issue in numpy: np.bool_ should define the __index__() 
method, no?

$ python3
Python 3.7.4 (default, Jul  9 2019, 16:32:37) 
>>> import numpy
>>> b=numpy.bool_(True)
>>> b.__int__()
1
>>> b.__index__()
__main__:1: DeprecationWarning: In future, it will be an error for 'np.bool_' 
scalars to be interpreted as an index
1

The purpose of the DeprecationWarning is to give time to numpy developers to 
update the bool_() type, before it becomes an error.

I'm not sure of the purpose of this issue, is it just to notice core developers 
that numpy should be updated? Or do you consider that type.__index__() must 
continue to fallback on type.__int__() if __index__() is not defined?

In the past, Python was tolerant in term of accepted types. It was hidding some 
bugs sometimes. We would like to make Python more strict to reduce the risk of 
bugs. Sadly, it requires to modify your Python code. It's like bytes/str which 
was strictly separeted in Python 3.0, except that here there is longer and 
smoother transition period :-)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37980>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to