diff -r 82be592d764d Lib/shutil.py --- a/Lib/shutil.py Tue Jan 29 18:17:05 2013 +0100 +++ b/Lib/shutil.py Thu Jan 31 22:41:41 2013 +0100 @@ -140,7 +140,13 @@ """ - for name in os.listxattr(src, follow_symlinks=follow_symlinks): + try: + names = os.listxattr(src, follow_symlinks=follow_symlinks) + except OSError as e: + if e.errno not in (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) diff -r 82be592d764d Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py Tue Jan 29 18:17:05 2013 +0100 +++ b/Lib/test/test_shutil.py Thu Jan 31 22:41:41 2013 +0100 @@ -450,6 +450,17 @@ self.assertIn('user.bar', os.listxattr(dst)) finally: os.setxattr = orig_setxattr + # the source filesystem not supporting xattrs should be ok, too. + def _raise_on_src(fname, *, follow_symlinks=True): + if fname == src: + raise OSError(errno.ENOTSUP, 'Operation not supported') + return orig_listxattr(fname, follow_symlinks=follow_symlinks) + try: + orig_listxattr = os.listxattr + os.listxattr = _raise_on_src + shutil._copyxattr(src, dst) + finally: + os.listxattr = orig_listxattr # test that shutil.copystat copies xattrs src = os.path.join(tmp_dir, 'the_original')