[issue31940] copystat on symlinks fails for alpine -- faulty lchmod implementation?

Anthony Sottile report at bugs.python.org
Fri Nov 3 20:14:49 EDT 2017


Anthony Sottile <asottile at umich.edu> added the comment:

Here's one idea for a patch (inspired by the rest of the function):

```
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 464ee91..2099289 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -213,6 +213,13 @@ def copystat(src, dst, *, follow_symlinks=True):
         # symlink.  give up, suppress the error.
         # (which is what shutil always did in this circumstance.)
         pass
+    except OSError as why:
+        # lchmod on alpine will raise this with symlinks: #31940
+        for err in 'EOPNOTSUPP', 'ENOTSUP':
+            if hasattr(errno, err) and why.errno == getattr(errno, err):
+                break
+        else:
+            raise
     if hasattr(st, 'st_flags'):
         try:
             lookup("chflags")(dst, st.st_flags, follow_symlinks=follow)
```

However lchmod seems to be just broken on alpine so the tests continue to fail (however my usecase is fixed)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31940>
_______________________________________


More information about the Python-bugs-list mailing list