bpo-24564: shutil.copystat(): ignore EINVAL on os.setxattr() by giampaolo · Pull Request #8601 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation9 Commits1 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

giampaolo

@giampaolo

@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

serhiy-storchaka

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

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.

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,

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

errno.EINVAL}:
errno.EINVAL):

@vstinner

@yingw787

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

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

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

@gpshead

closing as a new PR superceded this one.