<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def set_umask(mask):
    '''
    Temporarily set the umask and restore once the contextmanager exits
    '''
    if mask is None or salt.utils.platform.is_windows():
        # Don't attempt on Windows, or if no mask was passed
        yield
    else:
        try:
            orig_mask = os.umask(mask)  # pylint: disable=blacklisted-function
            yield
        finally:
            os.umask(orig_mask)