Issue #14082: shutil.copy2() now copies extended attributes, if possible.

Patch by Hynek Schlawack.
This commit is contained in:
Antoine Pitrou 2012-05-12 19:02:01 +02:00
parent 4d688e3275
commit 424246fbf3
6 changed files with 141 additions and 22 deletions

View file

@ -1810,25 +1810,7 @@ class TestSendfile(unittest.TestCase):
raise
def supports_extended_attributes():
if not hasattr(os, "setxattr"):
return False
try:
with open(support.TESTFN, "wb") as fp:
try:
os.fsetxattr(fp.fileno(), b"user.test", b"")
except OSError:
return False
finally:
support.unlink(support.TESTFN)
# Kernels < 2.6.39 don't respect setxattr flags.
kernel_version = platform.release()
m = re.match("2.6.(\d{1,2})", kernel_version)
return m is None or int(m.group(1)) >= 39
@unittest.skipUnless(supports_extended_attributes(),
"no non-broken extended attribute support")
@support.skip_unless_xattr
class ExtendedAttributeTests(unittest.TestCase):
def tearDown(self):