Skip to content

Commit f1487b3

Browse files
miss-islingtonyingw787
authored andcommitted
bpo-24564: shutil.copystat(): ignore EINVAL on os.setxattr() (GH-13369)
(cherry picked from commit a16387a) Co-authored-by: Ying Wang <[email protected]>
1 parent 3a98bbf commit f1487b3

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
@@ -156,15 +156,16 @@ def _copyxattr(src, dst, *, follow_symlinks=True):
156156
try:
157157
names = os.listxattr(src, follow_symlinks=follow_symlinks)
158158
except OSError as e:
159-
if e.errno not in (errno.ENOTSUP, errno.ENODATA):
159+
if e.errno not in (errno.ENOTSUP, errno.ENODATA, errno.EINVAL):
160160
raise
161161
return
162162
for name in names:
163163
try:
164164
value = os.getxattr(src, name, follow_symlinks=follow_symlinks)
165165
os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
166166
except OSError as e:
167-
if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA):
167+
if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA,
168+
errno.EINVAL):
168169
raise
169170
else:
170171
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)