Skip to content
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

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

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

@yingw787 yingw787 commented May 16, 2019

@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
Sponsor Contributor

@BoboTiG BoboTiG left a comment

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
Sponsor Contributor

@BoboTiG BoboTiG May 18, 2019

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

@yingw787 yingw787 May 18, 2019

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

@giampaolo giampaolo May 28, 2019

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

@yingw787 yingw787 May 29, 2019

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

@bedevere-bot bedevere-bot commented May 28, 2019

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.

@giampaolo giampaolo merged commit a16387a into python:master May 30, 2019
5 checks passed
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented May 30, 2019

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

@miss-islington miss-islington commented May 30, 2019

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

@bedevere-bot bedevere-bot commented May 30, 2019

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 issue May 30, 2019
…H-13369)

(cherry picked from commit a16387a)

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

@miss-islington miss-islington commented May 30, 2019

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 issue 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants