def safe_int(value):
    """
    Attempt to convert the given value to an integer,
    returning None on failure.
    """
    try:
        return int(value)
    except (TypeError, ValueError):
        return None
