From 1edb4ec5859ace69d1eef31438a8d2b01f7868e4 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Wed, 29 May 2019 23:25:31 -0400 Subject: [PATCH] bpo-24564: shutil.copystat(): ignore EINVAL on os.setxattr() (GH-13369) (cherry picked from commit a16387ab2d85f19665920bb6ff91a7e57f59dd2a) Co-authored-by: Ying Wang --- Lib/shutil.py | 5 +++-- .../next/Library/2019-05-16-23-40-36.bpo-24564.lIwV_7.rst | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2019-05-16-23-40-36.bpo-24564.lIwV_7.rst diff --git a/Lib/shutil.py b/Lib/shutil.py index 4c6fdd7d33d49c..fc6fb4edd24c15 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 00000000000000..27cb6178b54e46 --- /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.