From fbe5409a3bebeee9c729a21e2c88a3f93c26e992 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 16 Oct 2013 14:41:02 -0400 Subject: [PATCH] movefile: simplify xattr fallback logic The "with open()" construct handles exceptions just fine. --- pym/portage/util/movefile.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pym/portage/util/movefile.py b/pym/portage/util/movefile.py index 65d81c6bb..4f158cd00 100644 --- a/pym/portage/util/movefile.py +++ b/pym/portage/util/movefile.py @@ -128,15 +128,11 @@ else: "does not support extended attribute '%s'") % (_unicode_decode(dest), _unicode_decode(attr))) else: - _devnull = open("/dev/null", "wb") try: - subprocess.call(["getfattr", "--version"], stdout=_devnull) - subprocess.call(["setfattr", "--version"], stdout=_devnull) - _has_getfattr_and_setfattr = True + with open(os.devnull, 'wb') as f: + subprocess.call(["getfattr", "--version"], stdout=f) + subprocess.call(["setfattr", "--version"], stdout=f) except OSError: - _has_getfattr_and_setfattr = False - _devnull.close() - if _has_getfattr_and_setfattr: def _copyxattr(src, dest, exclude=None): # TODO: implement exclude getfattr_process = subprocess.Popen(["getfattr", "-d", "--absolute-names", src], stdout=subprocess.PIPE) -- 2.26.2