import io


def _is_real_file(f):
    """Checks if f is backed by a real file (has a fileno)"""
    try:
        return f.fileno() >= 0
    except io.UnsupportedOperation:
        return False
    except AttributeError:
        return False