# Buggy code
def _convert_to_indexer(self, obj, axis=None, is_setter=False):
    """
    Convert indexing key into something we can use to do actual fancy
    indexing on an ndarray

    Examples
    ix[:5] -> slice(0, 5)
    ix[[1,2,3]] -> [1,2,3]
    ix[['foo', 'bar', 'baz']] -> [i, j, k] (indices of foo, bar, baz)

    Going by Zen of Python?
    'In the face of ambiguity, refuse the temptation to guess.'
    raise AmbiguousIndexError with integer labels?
    - No, prefer label-based indexing
    """
    if axis is None:
        axis = self.axis or 0

    labels = self.obj._get_axis(axis)

    if isinstance(obj, slice):
        return self._convert_slice_indexer(obj, axis)

    # try to find out correct indexer, if not type correct raise
    try:
        obj = self._convert_scalar_indexer(obj, axis)
    except TypeError:
        # but we will allow setting
        if is_setter:
            pass

    # see if we are positional in nature
    is_int_index = labels.is_integer()
    is_int_positional = is_integer(obj) and not is_int_index

    # if we are a label return me
    try:
        return labels.get_loc(obj)
    except LookupError:
        if isinstance(obj, tuple) and isinstance(labels, MultiIndex):
            if is_setter and len(obj) == labels.nlevels:
                return {"key": obj}
            raise
    except TypeError:
        pass
    except ValueError:
        if not is_int_positional:
            raise

    # a positional
    if is_int_positional:
        # if we are setting and its not a valid location
        # its an insert which fails by definition
        if is_setter:
            # always valid
            if self.name == "loc":
                return {"key": obj}

            # a positional
            if obj >= self.obj.shape[axis] and not isinstance(labels, MultiIndex):
                raise ValueError("cannot set by positional indexing with enlargement")

        return obj

    if is_nested_tuple(obj, labels):
        return labels.get_locs(obj)

    elif is_list_like_indexer(obj):
        if com.is_bool_indexer(obj):
            obj = check_bool_indexer(labels, obj)
            (inds,) = obj.nonzero()
            return inds
        else:
            # Have the index compute an indexer or return None
            # if it cannot handle
            indexer, objarr = labels._convert_listlike_indexer(obj, kind=self.name)
            if indexer is not None:
                return indexer

            # unique index
            if labels.is_unique:
                indexer = check = labels.get_indexer(objarr)

            # non-unique (dups)
            else:
                (indexer, missing) = labels.get_indexer_non_unique(objarr)
                # 'indexer' has dupes, create 'check' using 'missing'
                check = np.zeros_like(objarr)
                check[missing] = -1

            mask = check == -1
            if mask.any():
                raise KeyError("{mask} not in index".format(mask=objarr[mask]))

            return com._values_from_object(indexer)

    else:
        try:
            return labels.get_loc(obj)
        except LookupError:
            # allow a not found key only if we are a setter
            if not is_list_like_indexer(obj) and is_setter:
                return {"key": obj}
            raise


# Traceback (AttributeError)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-32-b0e70145e9a6> in <module>()
----> 1 df.loc[trange[bool_idx], "A"] += 1

/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py in __setitem__(self, key, value)
176         else:
177             key = com._apply_if_callable(key, self.obj)
--> 178         indexer = self._get_setitem_indexer(key)
179         self._setitem_with_indexer(indexer, value)
180

/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py in _get_setitem_indexer(self, key)
155         if isinstance(key, tuple):
156             try:
--> 157                 return self._convert_tuple(key, is_setter=True)
158             except IndexingError:
159                 pass

/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py in _convert_tuple(self, key, is_setter)
222                 if i >= self.obj.ndim:
223                     raise IndexingError('Too many indexers')
--> 224                 idx = self._convert_to_indexer(k, axis=i, is_setter=is_setter)
225                 keyidx.append(idx)
226         return tuple(keyidx)

/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py in _convert_to_indexer(self, obj, axis, is_setter)
1228
1229                 mask = check == -1
-> 1230                 if mask.any():
1231                     raise KeyError('%s not in index' % objarr[mask])
1232

AttributeError: 'bool' object has no attribute 'any'

# Fixed code
def _convert_to_indexer(self, obj, axis=None, is_setter=False):
    """
    Convert indexing key into something we can use to do actual fancy
    indexing on an ndarray

    Examples
    ix[:5] -> slice(0, 5)
    ix[[1,2,3]] -> [1,2,3]
    ix[['foo', 'bar', 'baz']] -> [i, j, k] (indices of foo, bar, baz)

    Going by Zen of Python?
    'In the face of ambiguity, refuse the temptation to guess.'
    raise AmbiguousIndexError with integer labels?
    - No, prefer label-based indexing
    """
    if axis is None:
        axis = self.axis or 0

    labels = self.obj._get_axis(axis)

    if isinstance(obj, slice):
        return self._convert_slice_indexer(obj, axis)

    # try to find out correct indexer, if not type correct raise
    try:
        obj = self._convert_scalar_indexer(obj, axis)
    except TypeError:
        # but we will allow setting
        if is_setter:
            pass

    # see if we are positional in nature
    is_int_index = labels.is_integer()
    is_int_positional = is_integer(obj) and not is_int_index

    # if we are a label return me
    try:
        return labels.get_loc(obj)
    except LookupError:
        if isinstance(obj, tuple) and isinstance(labels, MultiIndex):
            if is_setter and len(obj) == labels.nlevels:
                return {"key": obj}
            raise
    except TypeError:
        pass
    except ValueError:
        if not is_int_positional:
            raise

    # a positional
    if is_int_positional:
        # if we are setting and its not a valid location
        # its an insert which fails by definition
        if is_setter:
            # always valid
            if self.name == "loc":
                return {"key": obj}

            # a positional
            if obj >= self.obj.shape[axis] and not isinstance(labels, MultiIndex):
                raise ValueError("cannot set by positional indexing with enlargement")

        return obj

    if is_nested_tuple(obj, labels):
        return labels.get_locs(obj)

    elif is_list_like_indexer(obj):
        if com.is_bool_indexer(obj):
            obj = check_bool_indexer(labels, obj)
            (inds,) = obj.nonzero()
            return inds
        else:
            # Have the index compute an indexer or return None
            # if it cannot handle
            indexer, objarr = labels._convert_listlike_indexer(obj, kind=self.name)
            if indexer is not None:
                return indexer

            # unique index
            if labels.is_unique:
                indexer = check = labels.get_indexer(objarr)

            # non-unique (dups)
            else:
                (indexer, missing) = labels.get_indexer_non_unique(objarr)
                # 'indexer' has dupes, create 'check' using 'missing'
                check = np.zeros(len(objarr))
                check[missing] = -1

            mask = check == -1
            if mask.any():
                raise KeyError("{mask} not in index".format(mask=objarr[mask]))

            return com._values_from_object(indexer)

    else:
        try:
            return labels.get_loc(obj)
        except LookupError:
            # allow a not found key only if we are a setter
            if not is_list_like_indexer(obj) and is_setter:
                return {"key": obj}
            raise