Skip to content

Commit a16387a

Browse files
yingw787giampaolo
authored andcommitted
bpo-24564: shutil.copystat(): ignore EINVAL on os.setxattr() (GH-13369)
1 parent 8087831 commit a16387a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Lib/shutil.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,16 @@ def _copyxattr(src, dst, *, follow_symlinks=True):
309309
try:
310310
names = os.listxattr(src, follow_symlinks=follow_symlinks)
311311
except OSError as e:
312-
if e.errno not in (errno.ENOTSUP, errno.ENODATA):
312+
if e.errno not in (errno.ENOTSUP, errno.ENODATA, errno.EINVAL):
313313
raise
314314
return
315315
for name in names:
316316
try:
317317
value = os.getxattr(src, name, follow_symlinks=follow_symlinks)
318318
os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
319319
except OSError as e:
320-
if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA):
320+
if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA,
321+
errno.EINVAL):
321322
raise
322323
else:
323324
def _copyxattr(*args, **kwargs):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:func:`shutil.copystat` now ignores :const:`errno.EINVAL` on :func:`os.setxattr` which may occur when copying files on filesystems without extended attributes support.
2+
3+
Original patch by Giampaolo Rodola, updated by Ying Wang.

0 commit comments

Comments
 (0)