Use _AxisError.
@@ -917,7 +917,7 @@ cdef class ndarray:
if axis < 0:
axis += ndim
if not (0 <= axis < ndim):
- raise ValueError('Axis out of range')
+ raise _AxisError('Axis out of range')
length = data.shape[axis]
if isinstance(kth, int):
