diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-05-14 05:30:22 (GMT) |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2019-05-14 05:30:22 (GMT) |
commit | 0a5b88e7f23b671d63896619b13148b0e4e2b5dd (patch) | |
tree | efd4fa070f4f951fafb751e5a6a50223038e4768 /Lib/test/test_shutil.py | |
parent | da86bf7396c6509534a94407fe83e7106c9d5959 (diff) | |
download | cpython-0a5b88e7f23b671d63896619b13148b0e4e2b5dd.zip cpython-0a5b88e7f23b671d63896619b13148b0e4e2b5dd.tar.gz cpython-0a5b88e7f23b671d63896619b13148b0e4e2b5dd.tar.bz2 |
bpo-24538: Fix bug in shutil involving the copying of xattrs to read-only files. (PR-13212) (#13234)
Extended attributes can only be set on user-writeable files, but shutil previously
first chmod()ed the destination file to the source's permissions and then tried to
copy xattrs. This will cause failures if attempting to copy read-only files with
xattrs, as occurs with Git clones on Lustre FS.
(cherry picked from commit 79efbb719383386051c72f2ee932eeca8e033e6b)
Co-authored-by: Olexa Bilaniuk <obilaniu@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_shutil.py')
-rw-r--r-- | Lib/test/test_shutil.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index 197dd13..ef93239 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -464,12 +464,20 @@ class TestShutil(unittest.TestCase): # test that shutil.copystat copies xattrs src = os.path.join(tmp_dir, 'the_original') + srcro = os.path.join(tmp_dir, 'the_original_ro') write_file(src, src) + write_file(srcro, srcro) os.setxattr(src, 'user.the_value', b'fiddly') + os.setxattr(srcro, 'user.the_value', b'fiddly') + os.chmod(srcro, 0o444) dst = os.path.join(tmp_dir, 'the_copy') + dstro = os.path.join(tmp_dir, 'the_copy_ro') write_file(dst, dst) + write_file(dstro, dstro) shutil.copystat(src, dst) + shutil.copystat(srcro, dstro) self.assertEqual(os.getxattr(dst, 'user.the_value'), b'fiddly') + self.assertEqual(os.getxattr(dstro, 'user.the_value'), b'fiddly') @support.skip_unless_symlink @support.skip_unless_xattr |