]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-24564: shutil.copystat(): ignore EINVAL on os.setxattr() (GH-13369)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 30 May 2019 05:58:30 +0000 (22:58 -0700)
committerGiampaolo Rodola <g.rodola@gmail.com>
Thu, 30 May 2019 05:58:30 +0000 (13:58 +0800)
(cherry picked from commit a16387ab2d85f19665920bb6ff91a7e57f59dd2a)

Co-authored-by: Ying Wang <me@yingw787.com>
Lib/shutil.py
Misc/NEWS.d/next/Library/2019-05-16-23-40-36.bpo-24564.lIwV_7.rst [new file with mode: 0644]

index 4c6fdd7d33d49caa431bbc1cac97fd5e10d503ec..fc6fb4edd24c15dab829eac3ea9005fc341c4f2a 100644 (file)
@@ -156,7 +156,7 @@ if hasattr(os, 'listxattr'):
         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 @@ if hasattr(os, 'listxattr'):
                 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 (file)
index 0000000..27cb617
--- /dev/null
@@ -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.\r
+\r
+Original patch by Giampaolo Rodola, updated by Ying Wang.\r