# Buggy code
def __sub__(self, other):
    from pandas.core.index import Index
    from pandas.core.indexes.datetimes import DatetimeIndex
    from pandas.core.indexes.timedeltas import TimedeltaIndex
    from pandas.tseries.offsets import DateOffset

    if isinstance(other, TimedeltaIndex):
        return self._add_delta(-other)
    elif isinstance(self, TimedeltaIndex) and isinstance(other, Index):
        if not isinstance(other, TimedeltaIndex):
            raise TypeError(
                "cannot subtract TimedeltaIndex and {typ}".format(
                    typ=type(other).__name__
                )
            )
        return self._add_delta(-other)
    elif isinstance(other, DatetimeIndex):
        return self._sub_datelike(other)
    elif isinstance(other, Index):
        raise TypeError(
            "cannot subtract {typ1} and {typ2}".format(
                typ1=type(self).__name__, typ2=type(other).__name__
            )
        )
    elif isinstance(other, (DateOffset, timedelta, np.timedelta64)):
        return self._add_delta(-other)
    elif is_integer(other):
        return self.shift(-other)
    elif isinstance(other, datetime):
        return self._sub_datelike(other)
    elif isinstance(other, Period):
        return self._sub_period(other)
    else:  # pragma: no cover
        return NotImplemented


# Traceback (OverflowError)
In [9]: pd.to_timedelta(['24658 days 11:15:00', 'NaT']) + pd.Timestamp('1950-01-01')
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
<ipython-input-9-cc287bf4c401> in <module>()
----> 1 pd.to_timedelta(['24658 days 11:15:00', 'NaT']) + pd.Timestamp('1950-01-01')

~/conda/envs/xarray-py36/lib/python3.6/site-packages/pandas/core/indexes/datetimelike.py in __add__(self, other)
658                 return self.shift(other)
659             elif isinstance(other, (Timestamp, datetime)):
--> 660                 return self._add_datelike(other)
661             else:  # pragma: no cover
662                 return NotImplemented

~/conda/envs/xarray-py36/lib/python3.6/site-packages/pandas/core/indexes/timedeltas.py in _add_datelike(self, other)
354             other = Timestamp(other)
355             i8 = self.asi8
--> 356             result = checked_add_with_arr(i8, other.value)
357             result = self._maybe_mask_results(result, fill_value=iNaT)
358         return DatetimeIndex(result, name=self.name, copy=False)

~/conda/envs/xarray-py36/lib/python3.6/site-packages/pandas/core/algorithms.py in checked_add_with_arr(arr, b, arr_mask, b_mask)
889
890     if to_raise:
--> 891         raise OverflowError("Overflow in int64 addition")
892     return arr + b
893

OverflowError: Overflow in int64 addition

# Fixed code
def __sub__(self, other):
    from pandas.core.index import Index
    from pandas.core.indexes.datetimes import DatetimeIndex
    from pandas.core.indexes.timedeltas import TimedeltaIndex
    from pandas.tseries.offsets import DateOffset

    if isinstance(other, TimedeltaIndex):
        return self._add_delta(-other)
    elif isinstance(self, TimedeltaIndex) and isinstance(other, Index):
        if not isinstance(other, TimedeltaIndex):
            raise TypeError(
                "cannot subtract TimedeltaIndex and {typ}".format(
                    typ=type(other).__name__
                )
            )
        return self._add_delta(-other)
    elif isinstance(other, DatetimeIndex):
        return self._sub_datelike(other)
    elif isinstance(other, Index):
        raise TypeError(
            "cannot subtract {typ1} and {typ2}".format(
                typ1=type(self).__name__, typ2=type(other).__name__
            )
        )
    elif isinstance(other, (DateOffset, timedelta, np.timedelta64)):
        return self._add_delta(-other)
    elif is_integer(other):
        return self.shift(-other)
    elif isinstance(other, (datetime, np.datetime64)):
        return self._sub_datelike(other)
    elif isinstance(other, Period):
        return self._sub_period(other)
    else:  # pragma: no cover
        return NotImplemented