Skip to content

bpo-24564: shutil.copystat(): ignore EINVAL on os.setxattr() #13369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 30, 2019

Conversation

yingw787
Copy link
Contributor

@yingw787 yingw787 commented May 16, 2019

[First-time contribution]

Carbon copy of PR #8601, except using tuples instead of sets. New pull request needed because original repo fork no longer exists.

This pull request ignores errno.EINVAL (invalid argument) when copying over extended attributes, which may cause copy to fail when copying files from a filesystem that supports extended attributes to filesystem that does not support extended attributes.

This pull request may also address bpo-36850.

CC: @giampaolo @serhiy-storchaka @abadger

https://bugs.python.org/issue24564

…n setting extended attributes using os.setxattr().
@yingw787
Copy link
Contributor Author

@abadger I am not sure how to add labels, but I believe #8601 needed a backport to 3.7 and 2.7 as they are currently accepting bugfixes (or maybe just 3.7 if 2.7 bugfix support will be dropped in 2020).

Copy link
Contributor

@BoboTiG BoboTiG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @yingw787 for your first contribution :) 🍾
LTGM, even better if you would take into account my remark on the NEWs entry ;)

@@ -0,0 +1,3 @@
shutil.copystat(): ignore EINVAL on os.setxattr() which may occur when copying files on NFS filesystems.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind adding markup and reword the NEWs entry? I think something like that could be good (think to use blurb to format correctly the lines):

: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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds great, should be pushed 👍

Lib/shutil.py Outdated
raise
return
for name in names:
try:
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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a cosmetic/style nitpick - it's better to do this:

                if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA,
                                   errno.EINVAL):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be updated!

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@miss-islington
Copy link
Contributor

Thanks @yingw787 for the PR, and @giampaolo for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @yingw787 for the PR, and @giampaolo for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-13673 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 30, 2019
…H-13369)

(cherry picked from commit a16387a)

Co-authored-by: Ying Wang <me@yingw787.com>
@miss-islington
Copy link
Contributor

Sorry, @yingw787 and @giampaolo, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker a16387ab2d85f19665920bb6ff91a7e57f59dd2a 2.7

giampaolo pushed a commit that referenced this pull request May 30, 2019
(cherry picked from commit a16387a)

Co-authored-by: Ying Wang <me@yingw787.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants