def getsource(obj):
    """Wrapper around inspect.getsource"""
    try:
        try:
            src = to_text_string(inspect.getsource(obj))
        except TypeError:
            if hasattr(obj, '__class__'):
                src = to_text_string(inspect.getsource(obj.__class__))
            else:
                # Bindings like VTK or ITK require this case
                src = getdoc(obj)
        return src
    except (TypeError, IOError):
        return
Wrapper around inspect.getsource