# Buggy code
def searchsorted(self, value, side="left", sorter=None):
    if isinstance(value, Period):
        if value.freq != self.freq:
            msg = DIFFERENT_FREQ_INDEX.format(self.freqstr, value.freqstr)
            raise IncompatibleFrequency(msg)
        value = value.ordinal
    elif isinstance(value, compat.string_types):
        value = Period(value, freq=self.freq).ordinal

    return self._ndarray_values.searchsorted(value, side=side, sorter=sorter)


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()

TypeError: an integer is required

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
~/.virtualenvs/shackleton3/lib/python3.7/site-packages/pandas/core/indexes/period.py in get_loc(self, key, method, tolerance)
881         try:
--> 882             return self._engine.get_loc(key)
883         except KeyError:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

KeyError: '__next__'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
pandas/_libs/tslibs/parsing.pyx in pandas._libs.tslibs.parsing.parse_datetime_string_with_reso()

pandas/_libs/tslibs/parsing.pyx in pandas._libs.tslibs.parsing.dateutil_parse()

ValueError: Unknown datetime string format, unable to parse: __next__

During handling of the above exception, another exception occurred:

DateParseError                            Traceback (most recent call last)
<ipython-input-9-81179fad4d42> in <module>()
3 index = pandas.MultiIndex.from_tuples(tuples)
4 s = pandas.Series([1.0], index=index)
----> 5 print(s[~s.isnull()])

~/.virtualenvs/shackleton3/lib/python3.7/site-packages/pandas/core/series.py in __getitem__(self, key)
802             raise
803
--> 804         if is_iterator(key):
805             key = list(key)
806

~/.virtualenvs/shackleton3/lib/python3.7/site-packages/pandas/core/dtypes/inference.py in is_iterator(obj)
153         # Python 3 generators have
154         # __next__ instead of next
--> 155         return hasattr(obj, '__next__')
156
157

~/.virtualenvs/shackleton3/lib/python3.7/site-packages/pandas/core/generic.py in __getattr__(self, name)
4372             return object.__getattribute__(self, name)
4373         else:
-> 4374             if self._info_axis._can_hold_identifiers_and_holds_name(name):
4375                 return self[name]
4376             return object.__getattribute__(self, name)

~/.virtualenvs/shackleton3/lib/python3.7/site-packages/pandas/core/indexes/base.py in _can_hold_identifiers_and_holds_name(self, name)
2109         """
2110         if self.is_object() or self.is_categorical():
-> 2111             return name in self
2112         return False
2113

~/.virtualenvs/shackleton3/lib/python3.7/site-packages/pandas/core/indexes/multi.py in __contains__(self, key)
547         hash(key)
548         try:
--> 549             self.get_loc(key)
550             return True
551         except (LookupError, TypeError):

~/.virtualenvs/shackleton3/lib/python3.7/site-packages/pandas/core/indexes/multi.py in get_loc(self, key, method)
2235
2236         if not isinstance(key, tuple):
-> 2237             loc = self._get_level_indexer(key, level=0)
2238
2239             # _get_level_indexer returns an empty slice if the key has

~/.virtualenvs/shackleton3/lib/python3.7/site-packages/pandas/core/indexes/multi.py in _get_level_indexer(self, key, level, indexer)
2494         else:
2495
-> 2496             loc = level_index.get_loc(key)
2497             if isinstance(loc, slice):
2498                 return loc

~/.virtualenvs/shackleton3/lib/python3.7/site-packages/pandas/core/indexes/period.py in get_loc(self, key, method, tolerance)
886
887             try:
--> 888                 asdt, parsed, reso = parse_time_string(key, self.freq)
889                 key = asdt
890             except TypeError:

pandas/_libs/tslibs/parsing.pyx in pandas._libs.tslibs.parsing.parse_time_string()

pandas/_libs/tslibs/parsing.pyx in pandas._libs.tslibs.parsing.parse_datetime_string_with_reso()

DateParseError: Unknown datetime string format, unable to parse: __next__

# Fixed code
def searchsorted(self, value, side="left", sorter=None):
    if isinstance(value, Period):
        if value.freq != self.freq:
            msg = DIFFERENT_FREQ_INDEX.format(self.freqstr, value.freqstr)
            raise IncompatibleFrequency(msg)
        value = value.ordinal
    elif isinstance(value, compat.string_types):
        try:
            value = Period(value, freq=self.freq).ordinal
        except DateParseError:
            raise KeyError("Cannot interpret '{}' as period".format(value))

    return self._ndarray_values.searchsorted(value, side=side, sorter=sorter)