diff --git a/Lib/shutil.py b/Lib/shutil.py index a4ce2c0290bc93..5ae0a20b112988 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -317,7 +317,8 @@ 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, errno.EINVAL): + if e.errno not in (errno.ENOTSUP, errno.ENODATA, errno.EINVAL, + errno.ENOSYS): raise return for name in names: @@ -325,8 +326,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, - errno.EINVAL): + if e.errno not in (errno.EPERM, errno.EACCES, errno.ENOTSUP, + errno.ENODATA, errno.EINVAL): raise else: def _copyxattr(*args, **kwargs): diff --git a/Misc/NEWS.d/next/Library/2020-07-10-11-01-44.bpo-38893.HNE1L4.rst b/Misc/NEWS.d/next/Library/2020-07-10-11-01-44.bpo-38893.HNE1L4.rst new file mode 100644 index 00000000000000..00b59bdabb144d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-07-10-11-01-44.bpo-38893.HNE1L4.rst @@ -0,0 +1,5 @@ +:func:`shutil.copystat` now ignores :const:`errno.ENOSYS` and +:const:`errno.EACCES` when copying extended file attributes. +:func:`os.listxattr` can fail with ENOSYS on some file systems (e.g. NFS). +An LSM may block :func:`os.setxattr` for security attributes like +``security.selinux``.