<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _apply_diff(environ, diff):
 """Apply a frozen environment. :param dict diff: key-value pairs to apply to the environment. :returns: A dict of the key-value pairs that are being changed. """

    original = {}

    if diff:
        for k, v in diff.iteritems():

            if v is None:
                log.log(5, 'unset %s', k)
            else:
                log.log(5, '%s="%s"', k, v)

            original[k] = environ.get(k)

            if original[k] is None:
                log.log(1, '%s was not set', k)
            else:
                log.log(1, '%s was "%s"', k, original[k])

            if v is None:
                environ.pop(k, None)
            else:
                environ[k] = v
    else:
        log.log(5, 'nothing to apply')

    return original