# Buggy code
def _getitem_iterable(self, key, axis=None):
    if axis is None:
        axis = self.axis or 0

    if self._should_validate_iterable(axis):
        self._has_valid_type(key, axis)

    labels = self.obj._get_axis(axis)

    if com.is_bool_indexer(key):
        key = check_bool_indexer(labels, key)
        (inds,) = key.nonzero()
        return self.obj._take(inds, axis=axis, convert=False)
    else:
        # Have the index compute an indexer or return None
        # if it cannot handle; we only act on all found values
        indexer, keyarr = labels._convert_listlike_indexer(key, kind=self.name)
        if indexer is not None and (indexer != -1).all():
            return self.obj.take(indexer, axis=axis)

        # existing labels are unique and indexer are unique
        if labels.is_unique and Index(keyarr).is_unique:
            try:
                return self.obj.reindex(keyarr, axis=axis)
            except AttributeError:
                # Series
                if axis != 0:
                    raise AssertionError("axis must be 0")
                return self.obj.reindex(keyarr)

        # existing labels are non-unique
        else:
            # reindex with the specified axis
            if axis + 1 > self.obj.ndim:
                raise AssertionError("invalid indexing error with non-unique index")

            new_target, indexer, new_indexer = labels._reindex_non_unique(keyarr)

            if new_indexer is not None:
                result = self.obj._take(
                    indexer[indexer != -1], axis=axis, convert=False
                )

                result = result._reindex_with_indexers(
                    {axis: [new_target, new_indexer]}, copy=True, allow_dups=True
                )

            else:
                result = self.obj._take(indexer, axis=axis)

            return result


# 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 _getitem_iterable(self, key, axis=None):
    if axis is None:
        axis = self.axis or 0

    self._validate_key(key, axis)

    labels = self.obj._get_axis(axis)

    if com.is_bool_indexer(key):
        key = check_bool_indexer(labels, key)
        (inds,) = key.nonzero()
        return self.obj._take(inds, axis=axis, convert=False)
    else:
        # Have the index compute an indexer or return None
        # if it cannot handle; we only act on all found values
        indexer, keyarr = labels._convert_listlike_indexer(key, kind=self.name)
        if indexer is not None and (indexer != -1).all():
            self._validate_read_indexer(key, indexer, axis)
            return self.obj.take(indexer, axis=axis)

        ax = self.obj._get_axis(axis)
        # existing labels are unique and indexer are unique
        if labels.is_unique and Index(keyarr).is_unique:
            indexer = ax.get_indexer_for(key)
            self._validate_read_indexer(key, indexer, axis)

            d = {axis: [ax.reindex(keyarr)[0], indexer]}
            return self.obj._reindex_with_indexers(d, copy=True, allow_dups=True)

        # existing labels are non-unique
        else:
            # reindex with the specified axis
            if axis + 1 > self.obj.ndim:
                raise AssertionError("invalid indexing error with non-unique index")

            new_target, indexer, new_indexer = labels._reindex_non_unique(keyarr)

            if new_indexer is not None:
                result = self.obj._take(
                    indexer[indexer != -1], axis=axis, convert=False
                )

                self._validate_read_indexer(key, new_indexer, axis)
                result = result._reindex_with_indexers(
                    {axis: [new_target, new_indexer]}, copy=True, allow_dups=True
                )

            else:
                self._validate_read_indexer(key, indexer, axis)
                result = self.obj._take(indexer, axis=axis)

            return result