This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients ammar2, mark.dickinson, rhettinger, seberg, serhiy.storchaka, tcaswell, terry.reedy, tim.peters, vstinner
Date 2019-08-30.11:02:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1567162921.51.0.252397719171.issue37980@roundup.psfhosted.org>
In-reply-to
Content
> 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 :-)
History
Date User Action Args
2019-08-30 11:02:01vstinnersetrecipients: + vstinner, tim.peters, rhettinger, terry.reedy, mark.dickinson, serhiy.storchaka, seberg, tcaswell, ammar2
2019-08-30 11:02:01vstinnersetmessageid: <1567162921.51.0.252397719171.issue37980@roundup.psfhosted.org>
2019-08-30 11:02:01vstinnerlinkissue37980 messages
2019-08-30 11:02:01vstinnercreate