Skip to content

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

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

Closed
wants to merge 1 commit into from
Closed

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

wants to merge 1 commit into from

Conversation

giampaolo
Copy link
Contributor

@giampaolo giampaolo commented Aug 1, 2018

@giampaolo giampaolo added type-bug An unexpected behavior, bug, or error CLA signed labels Aug 1, 2018
@serhiy-storchaka serhiy-storchaka changed the title #24564 - shutil.copystat(): ignore EINVAL on os.setxattr() bpo-24564: shutil.copystat(): ignore EINVAL on os.setxattr() Dec 8, 2018
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM in general. Just added minor suggestions. And would be nice to add tests.

@@ -297,15 +297,16 @@ 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):
if e.errno not in {errno.ENOTSUP, errno.ENODATA, errno.EINVAL}:
Copy link
Member

Choose a reason for hiding this comment

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

There is no benefit from using a set instead of a tuple. Building a set is more expensive than builtin a tuple.

Suggested change
if e.errno not in {errno.ENOTSUP, errno.ENODATA, errno.EINVAL}:
if e.errno not in (errno.ENOTSUP, errno.ENODATA, errno.EINVAL):

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,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if e.errno not in {errno.EPERM, errno.ENOTSUP, errno.ENODATA,
if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA,

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
Member

Choose a reason for hiding this comment

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

Suggested change
errno.EINVAL}:
errno.EINVAL):

@vstinner
Copy link
Member

I removed the " needs backport to 3.6" label, the 3.6 branch no longer accept bugfixes (only security fixes are accepted): https://devguide.python.org/#status-of-python-branches

@yingw787
Copy link
Contributor

yingw787 commented May 9, 2019

Hey @serhiy-storchaka @giampaolo! I'm a first time CPython contributor and I was taking a look at bpo-36850 that ties into bpo-24564. Are we still waiting for a higher authority to approve ignoring EINVAL on os.setxattr() (I reviewed the bpos with @abadger and we didn't see anybody saying yay/nay)? I can add some unit tests with mock, but I'm not sure how useful that may be. How are filesystem copy() methods tested with network filesystems? Should we run a Docker container with CIFS/NFS and try to copy over a small file to local with xatttrs()? Not sure how that may integrate with the Python test suite.

@giampaolo
Copy link
Contributor Author

The patch is OK except that tuples should be used instead of sets (as per Serhiy’s review comment). The PR points to a GiT repo/branch which no longer exists though so a new PR should be submitted. I am currently traveling and am short on time though, so if you want to take over be my guest. (and no, no need of additional tests)

@yingw787
Copy link
Contributor

@giampaolo thank you for the response! I will open a new pull request with these changes and the tuple/set changes.

@gpshead
Copy link
Member

gpshead commented Sep 28, 2019

closing as a new PR superceded this one.

@gpshead gpshead closed this Sep 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting merge type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants