From: Mike Frysinger Date: Wed, 16 Oct 2013 18:41:02 +0000 (-0400) Subject: movefile: simplify xattr fallback logic X-Git-Tag: v2.2.8~55 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fbe5409a3bebeee9c729a21e2c88a3f93c26e992;p=portage.git movefile: simplify xattr fallback logic The "with open()" construct handles exceptions just fine. --- 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)