# Buggy code
def _has_valid_tuple(self, key):
    """check the key for valid keys across my indexer"""
    for i, k in enumerate(key):
        if i >= self.obj.ndim:
            raise IndexingError("Too many indexers")
        if not self._has_valid_type(k, i):
            raise ValueError(
                "Location based indexing can only have [{types}] types".format(
                    types=self._valid_types
                )
            )


# Traceback (KeyError)
In [2]: pd.Series(range(3)).ix[5]
/usr/bin/ipython3:1: DeprecationWarning:
.ix is deprecated. Please use
.loc for label based indexing or
.iloc for positional indexing

See the documentation here:
http://pandas.pydata.org/pandas-docs/stable/indexing.html#ix-indexer-is-deprecated
#! /bin/sh
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/home/nobackup/repo/pandas/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
3017             try:
-> 3018                 return self._engine.get_loc(key)
3019             except KeyError:

/home/nobackup/repo/pandas/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5729)()
138
--> 139     cpdef get_loc(self, object val):
140         if is_definitely_invalid_key(val):

/home/nobackup/repo/pandas/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5575)()
160         try:
--> 161             return self.mapping.get_item(val)
162         except (TypeError, ValueError):

/home/nobackup/repo/pandas/pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item (pandas/_libs/hashtable.c:15398)()
957
--> 958     cpdef get_item(self, int64_t val):
959         cdef khiter_t k

/home/nobackup/repo/pandas/pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item (pandas/_libs/hashtable.c:15342)()
963         else:
--> 964             raise KeyError(val)
965

KeyError: 5

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
/home/nobackup/repo/pandas/pandas/core/indexing.py in _get_label(self, label, axis)
131             try:
--> 132                 return self.obj._xs(label, axis=axis)
133             except:

/home/nobackup/repo/pandas/pandas/core/generic.py in xs(self, key, axis, level, drop_level)
2991         else:
-> 2992             loc = self.index.get_loc(key)
2993

/home/nobackup/repo/pandas/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
3019             except KeyError:
-> 3020                 return self._engine.get_loc(self._maybe_cast_indexer(key))
3021

/home/nobackup/repo/pandas/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5729)()
138
--> 139     cpdef get_loc(self, object val):
140         if is_definitely_invalid_key(val):

/home/nobackup/repo/pandas/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5575)()
160         try:
--> 161             return self.mapping.get_item(val)
162         except (TypeError, ValueError):

/home/nobackup/repo/pandas/pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item (pandas/_libs/hashtable.c:15398)()
957
--> 958     cpdef get_item(self, int64_t val):
959         cdef khiter_t k

/home/nobackup/repo/pandas/pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item (pandas/_libs/hashtable.c:15342)()
963         else:
--> 964             raise KeyError(val)
965

KeyError: 5

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-2-bba00cd402c6> in <module>()
----> 1 pd.Series(range(3)).ix[5]

/home/nobackup/repo/pandas/pandas/core/indexing.py in __getitem__(self, key)
118
119             key = com._apply_if_callable(key, self.obj)
--> 120             return self._getitem_axis(key, axis=axis)
121
122     def _get_label(self, label, axis=None):

/home/nobackup/repo/pandas/pandas/core/indexing.py in _getitem_axis(self, key, axis)
1104                     return self._get_loc(key, axis=axis)
1105
-> 1106             return self._get_label(key, axis=axis)
1107
1108     def _getitem_iterable(self, key, axis=None):

/home/nobackup/repo/pandas/pandas/core/indexing.py in _get_label(self, label, axis)
132                 return self.obj._xs(label, axis=axis)
133             except:
--> 134                 return self.obj[label]
135         elif isinstance(label, tuple) and isinstance(label[axis], slice):
136             raise IndexingError('no slices here, handle elsewhere')

/home/nobackup/repo/pandas/pandas/core/series.py in __getitem__(self, key)
753         key = com._apply_if_callable(key, self)
754         try:
--> 755             result = self.index.get_value(self, key)
756
757             if not is_scalar(result):

/home/nobackup/repo/pandas/pandas/core/indexes/base.py in get_value(self, series, key)
3051         try:
3052             return self._engine.get_value(s, k,
-> 3053                                           tz=getattr(series.dtype, 'tz', None))
3054         except KeyError as e1:
3055             if len(self) > 0 and self.inferred_type in ['integer', 'boolean']:

/home/nobackup/repo/pandas/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_value (pandas/_libs/index.c:4856)()
103         return val in self.mapping
104
--> 105     cpdef get_value(self, ndarray arr, object key, object tz=None):
106         """
107         arr : 1-dimensional ndarray

/home/nobackup/repo/pandas/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_value (pandas/_libs/index.c:4539)()
111             void* data_ptr
112
--> 113         loc = self.get_loc(key)
114         if PySlice_Check(loc) or cnp.PyArray_Check(loc):
115             return arr[loc]

/home/nobackup/repo/pandas/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5575)()
159
160         try:
--> 161             return self.mapping.get_item(val)
162         except (TypeError, ValueError):
163             raise KeyError(val)

/home/nobackup/repo/pandas/pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item (pandas/_libs/hashtable.c:15398)()
956                                        sizeof(uint32_t)) # flags
957
--> 958     cpdef get_item(self, int64_t val):
959         cdef khiter_t k
960         k = kh_get_int64(self.table, val)

/home/nobackup/repo/pandas/pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item (pandas/_libs/hashtable.c:15342)()
962             return self.table.vals[k]
963         else:
--> 964             raise KeyError(val)
965
966     cpdef set_item(self, int64_t key, Py_ssize_t val):

KeyError: 5

In [3]: pd.Series(range(3)).ix[[5]]
/usr/bin/ipython3:1: DeprecationWarning:
.ix is deprecated. Please use
.loc for label based indexing or
.iloc for positional indexing

See the documentation here:
http://pandas.pydata.org/pandas-docs/stable/indexing.html#ix-indexer-is-deprecated
#! /bin/sh
Out[3]:
5   NaN
dtype: float64

# Fixed code
def _has_valid_tuple(self, key):
    """check the key for valid keys across my indexer"""
    for i, k in enumerate(key):
        if i >= self.obj.ndim:
            raise IndexingError("Too many indexers")
        try:
            self._validate_key(k, i)
        except ValueError:
            raise ValueError(
                "Location based indexing can only have [{types}] types".format(
                    types=self._valid_types
                )
            )