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() #8601

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
6 participants
@giampaolo
Copy link
Contributor

commented 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

@serhiy-storchaka
Copy link
Member

left a comment

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

This comment has been minimized.

Copy link
@serhiy-storchaka

serhiy-storchaka Dec 8, 2018

Member

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,

This comment has been minimized.

Copy link
@serhiy-storchaka

serhiy-storchaka Dec 8, 2018

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

This comment has been minimized.

Copy link
@serhiy-storchaka

serhiy-storchaka Dec 8, 2018

Member
Suggested change
errno.EINVAL}:
errno.EINVAL):
@vstinner

This comment has been minimized.

Copy link
Member

commented Jan 10, 2019

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor Author

commented May 9, 2019

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

This comment has been minimized.

Copy link

commented May 14, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.