# Buggy code
def _sub_datelike(self, other):
    # subtract a datetime from myself, yielding a TimedeltaIndex
    from pandas import TimedeltaIndex

    if isinstance(other, DatetimeIndex):
        # require tz compat
        if not self._has_same_tz(other):
            raise TypeError(
                "DatetimeIndex subtraction must have the same timezones or no timezones"
            )
        result = self._sub_datelike_dti(other)
    elif isinstance(other, datetime):
        other = Timestamp(other)
        if other is libts.NaT:
            result = self._nat_new(box=False)
        # require tz compat
        elif not self._has_same_tz(other):
            raise TypeError(
                "Timestamp subtraction must have the same timezones or no timezones"
            )
        else:
            i8 = self.asi8
            result = i8 - other.value
            result = self._maybe_mask_results(result, fill_value=libts.iNaT)
    else:
        raise TypeError(
            "cannot subtract DatetimeIndex and {typ}".format(typ=type(other).__name__)
        )
    return TimedeltaIndex(result, name=self.name, copy=False)


# 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_datelike(self, other):
    # subtract a datetime from myself, yielding a TimedeltaIndex
    from pandas import TimedeltaIndex

    if isinstance(other, DatetimeIndex):
        # require tz compat
        if not self._has_same_tz(other):
            raise TypeError(
                "DatetimeIndex subtraction must have the same timezones or no timezones"
            )
        result = self._sub_datelike_dti(other)
    elif isinstance(other, (datetime, np.datetime64)):
        other = Timestamp(other)
        if other is libts.NaT:
            result = self._nat_new(box=False)
        # require tz compat
        elif not self._has_same_tz(other):
            raise TypeError(
                "Timestamp subtraction must have the same timezones or no timezones"
            )
        else:
            i8 = self.asi8
            result = checked_add_with_arr(i8, -other.value, arr_mask=self._isnan)
            result = self._maybe_mask_results(result, fill_value=libts.iNaT)
    else:
        raise TypeError(
            "cannot subtract DatetimeIndex and {typ}".format(typ=type(other).__name__)
        )
    return TimedeltaIndex(result, name=self.name, copy=False)