# 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 is_timedelta64_dtype(other):
        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, (DateOffset, timedelta)):
        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)
    elif is_offsetlike(other):
        # Array/Index of DateOffset objects
        return self._sub_offset_array(other)
    elif isinstance(other, Index):
        raise TypeError(
            "cannot subtract {typ1} and {typ2}".format(
                typ1=type(self).__name__, typ2=type(other).__name__
            )
        )

    else:  # pragma: no cover
        return NotImplemented


# Traceback (TypeError)
dti + one
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pandas/core/indexes/datetimelike.py", line 685, in __add__
elif is_offsetlike(other):
File "pandas/core/dtypes/common.py", line 294, in is_offsetlike
elif (is_list_like(arr_or_obj) and len(arr_or_obj) and
TypeError: len() of unsized object

# 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

    other = lib.item_from_zerodim(other)
    if is_timedelta64_dtype(other):
        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, (DateOffset, timedelta)):
        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)
    elif is_offsetlike(other):
        # Array/Index of DateOffset objects
        return self._sub_offset_array(other)
    elif isinstance(other, Index):
        raise TypeError(
            "cannot subtract {typ1} and {typ2}".format(
                typ1=type(self).__name__, typ2=type(other).__name__
            )
        )

    else:  # pragma: no cover
        return NotImplemented