##### SUMMARY
See https://github.com/ansible/ansible/blob/88d8cf8197c53edd3bcdcd21429eb4c2bfbf0f6a/lib/ansible/module_utils/basic.py#L699-L706

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
lib/ansible/module_utils/basic.py

##### ANSIBLE VERSION
```paste below
2.9
devel
```

except Exception as e:
                path = to_text(b_path)
                self.fail_json(path=path, msg='chmod failed', details=to_native(e),
                               exception=traceback.format_exc())
            path_stat = os.lstat(b_path)
            new_mode = stat.S_IMODE(path_stat.st_mode)
            if new_mode != prev_mode:
                changed = True
        return changed
    def set_attributes_if_different(self, path, attributes, changed, diff=None, expand=True):
        if attributes is None:
            return changed
        b_path = to_bytes(path, errors='surrogate_or_strict')
        if expand:
            b_path = os.path.expanduser(os.path.expandvars(b_path))
        if self.check_file_absent_if_check_mode(b_path):
            return True
        existing = self.get_file_attributes(b_path)
        attr_mod = '='
        if attributes.startswith(('-', '+')):
            attr_mod = attributes[0]
            attributes = attributes[1:]
        if existing.get('attr_flags', '') != attributes or attr_mod == '-':
            attrcmd = self.get_bin_path('chattr')
            if attrcmd:
                attrcmd = [attrcmd, '%s%s' % (attr_mod, attributes), b_path]
                changed = True
                if diff is not None:
                    if 'before' not in diff:
                        diff['before'] = {}