[Python-checkins] bpo-24564: shutil.copystat(): ignore EINVAL on os.setxattr() (GH-13369)

Giampaolo Rodola webhook-mailer at python.org
Thu May 30 01:58:47 EDT 2019


https://github.com/python/cpython/commit/f1487b323549e2360460383b4304f6592fb38e27
commit: f1487b323549e2360460383b4304f6592fb38e27
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Giampaolo Rodola <g.rodola at gmail.com>
date: 2019-05-30T13:58:30+08:00
summary:

bpo-24564: shutil.copystat(): ignore EINVAL on os.setxattr() (GH-13369)

(cherry picked from commit a16387ab2d85f19665920bb6ff91a7e57f59dd2a)

Co-authored-by: Ying Wang <me at yingw787.com>

files:
A Misc/NEWS.d/next/Library/2019-05-16-23-40-36.bpo-24564.lIwV_7.rst
M Lib/shutil.py

diff --git a/Lib/shutil.py b/Lib/shutil.py
index 4c6fdd7d33d4..fc6fb4edd24c 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -156,7 +156,7 @@ def _copyxattr(src, dst, *, follow_symlinks=True):
         try:
             names = os.listxattr(src, follow_symlinks=follow_symlinks)
         except OSError as e:
-            if e.errno not in (errno.ENOTSUP, errno.ENODATA):
+            if e.errno not in (errno.ENOTSUP, errno.ENODATA, errno.EINVAL):
                 raise
             return
         for name in names:
@@ -164,7 +164,8 @@ def _copyxattr(src, dst, *, follow_symlinks=True):
                 value = os.getxattr(src, name, follow_symlinks=follow_symlinks)
                 os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
             except OSError as e:
-                if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA):
+                if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA,
+                                   errno.EINVAL):
                     raise
 else:
     def _copyxattr(*args, **kwargs):
diff --git a/Misc/NEWS.d/next/Library/2019-05-16-23-40-36.bpo-24564.lIwV_7.rst b/Misc/NEWS.d/next/Library/2019-05-16-23-40-36.bpo-24564.lIwV_7.rst
new file mode 100644
index 000000000000..27cb6178b54e
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-05-16-23-40-36.bpo-24564.lIwV_7.rst
@@ -0,0 +1,3 @@
+:func:`shutil.copystat` now ignores :const:`errno.EINVAL` on :func:`os.setxattr` which may occur when copying files on filesystems without extended attributes support.
+
+Original patch by Giampaolo Rodola, updated by Ying Wang.



More information about the Python-checkins mailing list