Fully qualified name for 'instancemethod' objects in Python 2.

def _fullqualname_method_py2(obj):
    """Fully qualified name for 'instancemethod' objects in Python 2.
    """

    if obj.__self__ is None:
        # unbound methods
        module = obj.im_class.__module__
        cls = obj.im_class.__name__
    else:
        # bound methods
        if inspect.isclass(obj.__self__):
            # methods decorated with @classmethod
            module = obj.__self__.__module__
            cls = obj.__self__.__name__
        else:
            module = obj.__self__.__class__.__module__
            cls = obj.__self__.__class__.__name__

    return module + '.' + cls + '.' + obj.__func__.__name__