Message180920
The new xattr support in shutil causes shutil.copytree and shutil.copy2 to fail inelegantly on (source) filesystems that do not support xattrs (like NFS):
# /home/twouters does not support xattrs
>>> os.listxattr("/home/twouters/foo")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 95] Operation not supported: '/home/twouters/foo'
>>> shutil.copytree("/home/twouters/spam", "/tmp/spam")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/twouters/gvs-pristine/python/Python-3.Lib/shutil.py", line 345, in copytree
raise Error(errors)
shutil.Error: [('/home/twouters/spam/ham', '/tmp/spam/ham', "[Errno 95] Operation not supported: '/home/twouters/spam/ham'"), ('/home/twouters/spam/eggs', '/tmp/spam/eggs', "[Errno 95] Operation not supported: '/home/twouters/spam/eggs'"), ('/home/twouters/spam', '/tmp/spam', "[Errno 95] Operation not supported: '/home/twouters/spam'")]
(The actual files will have been copied, since xattr copies are done after everything else.) Interestingly shutil._copyxattr does try to cope with unsupported xattrs on the *target* filesystem (which seems like it might be a mistake to do, since it loses data), just not the original filesystem (which seems like a sensible thing instead):
# /tmp does support xattrs
>>> os.listxattr("/tmp/spam")
[]
>>> shutil.copytree("/tmp/spam", "/home/twouters/spam-new")
'/home/twouters/spam-new'
The attached patch fixes shutil._copyxattr to also ignore unsupported/empty xattrs (but not permission errors) on the source. (I'm not certain if errno.ENODATA can be expected from os.listxattr(), but internet searches suggest that some people think so, and I don't know what other meaning it could have.) |
|
Date |
User |
Action |
Args |
2013-01-29 18:18:12 | twouters | set | recipients:
+ twouters |
2013-01-29 18:18:12 | twouters | set | messageid: <1359483492.58.0.639649244817.issue17076@psf.upfronthosting.co.za> |
2013-01-29 18:18:12 | twouters | link | issue17076 messages |
2013-01-29 18:18:12 | twouters | create | |
|