def _check_null(result, func, arguments):
    """Check that a ctypes function returned something else than null."""
    if result:
        return result
    func_name = getattr(func, '__name__', '__unknown__')
    raise OSError(func_name + '(' + ', '.join(map(str, arguments)) +
        ') returned null')
