From 8512701b4a41b4a7472975cc4c0a906d01b1a514 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sun, 12 Sep 2021 20:58:45 +0200 Subject: [PATCH] metadata: accept EOPNOTSUPP for lchmod() 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 Reviewed-by: Rob Browning --- lib/bup/metadata.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/bup/metadata.py b/lib/bup/metadata.py index a20b67b..83f04f7 100644 --- a/lib/bup/metadata.py +++ b/lib/bup/metadata.py @@ -453,8 +453,13 @@ class Metadata: 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)) -- 2.39.2