Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
BUG: Fixes #7395, operator.index now fails on numpy.bool_
  • Loading branch information
emilienkofman authored and eric-wieser committed Sep 14, 2017
commit 98d15b4c066b6fbccdce3d97130a563374b1c9ba
4 changes: 3 additions & 1 deletion numpy/core/src/multiarray/scalartypes.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -2843,7 +2843,9 @@ static PyNumberMethods @name@_arrtype_as_number;
static PyObject *
bool_index(PyObject *a)
{
return PyInt_FromLong(PyArrayScalar_VAL(a, Bool));
PyErr_SetString(PyExc_TypeError,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of raising an error here, isn't it easier to remove this whole definition and not define (or explicitly set to NULL; not sure) PyBoolArrType_Type.tp_as_number->nb_index? (it is currently defined in L4114).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good catch

"A boolean scalar cannot be converted to an index");
return NULL;
}

/* Arithmetic methods -- only so we can override &, |, ^. */
Expand Down