On some systems (e.g. mine, Fedora 33) python2 has
(started to have?) lchmod(), as glibc has it, but
that always only returns EOPNOTSUPP if you really
try to operate on a symlink. Allow for that and
handle it just like ENOSYS.
Note that the handling of ENOSYS is wrong, since
integers can't be thrown or caught - pylint found
this as well, but since I'm fixing EOPNOTSUPP here
I need to fix that at the same time.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
if _have_lchmod:
try:
os.lchmod(path, stat.S_IMODE(self.mode))
- except errno.ENOSYS: # Function not implemented
- pass
+ except OSError as e:
+ # - "Function not implemented"
+ # - "Operation not supported" might be generated by glibc
+ if e.errno in (errno.ENOSYS, errno.EOPNOTSUPP):
+ pass
+ else:
+ raise
elif not stat.S_ISLNK(self.mode):
os.chmod(path, stat.S_IMODE(self.mode))