[New-bugs-announce] [issue17076] shutil.copytree failing on xattr-less filesystems (like NFS)

Thomas Wouters report at bugs.python.org
Tue Jan 29 19:18:12 CET 2013


New submission from Thomas Wouters:

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.3.0/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.)

----------
files: shutil.patch
keywords: needs review, patch
messages: 180920
nosy: twouters
priority: high
severity: normal
stage: patch review
status: open
title: shutil.copytree failing on xattr-less filesystems (like NFS)
type: crash
versions: Python 3.3
Added file: http://bugs.python.org/file28898/shutil.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17076>
_______________________________________


More information about the New-bugs-announce mailing list