diff --git a/Lib/test/support.py b/Lib/test/support.py --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -24,6 +24,7 @@ import fnmatch import logging.handlers import struct +import tempfile try: import _thread, threading @@ -1694,9 +1695,13 @@ if not hasattr(os, "setxattr"): can = False else: + tmp_fp, tmp_name = tempfile.mkstemp() try: with open(TESTFN, "wb") as fp: try: + # TESTFN & tempfile may use different file systems with + # different capabilities + os.fsetxattr(tmp_fp, b"user.test", b"") os.fsetxattr(fp.fileno(), b"user.test", b"") # Kernels < 2.6.39 don't respect setxattr flags. kernel_version = platform.release() @@ -1706,6 +1711,7 @@ can = False finally: unlink(TESTFN) + unlink(tmp_name) _can_xattr = can return can