def python_2_format_compatible(method):
    """
    Handles bytestring and unicode inputs for the `__format__()` method in
    Python 2. This function has no effect in Python 3.

    :param method: The `__format__()` method to wrap.
    :return: The wrapped method.
    """
    if six.PY3:
        return method

    def wrapper(self, format_spec):
        formatted = method(self, format_spec)
        if isinstance(format_spec, str):
            # bytestring
            return formatted.encode('utf-8')

        # unicode
        return formatted
    return wrapper