def __exit__(self, exc_type, exc_val, exc_tb):
    if (not self._no_clean):
        self._temp_dir.cleanup()

    def restore_var(varname, old_value):
        if (old_value is None):
            os.environ.pop(varname, None)
        else:
            os.environ[varname] = old_value
    restore_var('PATH', self.save_path)
    restore_var('PYTHONPATH', self.save_pythonpath)
    restore_var('PYTHONNOUSERSITE', self.save_nousersite)
def __exit__(self, exc_type, exc_val, exc_tb):
    if (not self._no_clean):
        self._temp_dir.cleanup()

    def restore_var(varname, old_value):
        if (old_value is None):
            os.environ.pop(varname, None)
        else:
            os.environ[varname] = old_value
    restore_var('PATH', self.save_path)
    restore_var('PYTHONPATH', self.save_pythonpath)
    restore_var('PYTHONNOUSERSITE', self.save_nousersite)