Skip to content

regression in py38 with bool-as-index deprecation warning #14397

Open
@tacaswell

Description

@tacaswell

Also reported upstream at https://bugs.python.org/issue37980

With numpy 1.17.1 and python37 the following does not warn

sorted([1, 2], reverse=np.bool_(True))

but with py38

In [2]: sorted([1, 2], reverse=np.bool_(True))                                                                                                                  
<ipython-input-2-6726f33270df>:1: DeprecationWarning: In future, it will be an error for 'np.bool_' scalars to be interpreted as an index
  sorted([1, 2], reverse=np.bool_(True))
Out[2]: [2, 1]

This bisects to python/cpython#11952 which use __index__ in more places which is tripping the deprecation in a surprising place.

sorted([1, 2], reverse=bool(np.bool_(True)))

Works in all cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions