From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 7087B1381F3 for ; Wed, 16 Oct 2013 20:48:04 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5C237E0839; Wed, 16 Oct 2013 20:48:00 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DF6B4E0839 for ; Wed, 16 Oct 2013 20:47:59 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E6A7033F063 for ; Wed, 16 Oct 2013 20:47:58 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 92DB0E5308 for ; Wed, 16 Oct 2013 20:47:57 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1381955581.fbe5409a3bebeee9c729a21e2c88a3f93c26e992.vapier@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/util/movefile.py X-VCS-Directories: pym/portage/util/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: fbe5409a3bebeee9c729a21e2c88a3f93c26e992 X-VCS-Branch: master Date: Wed, 16 Oct 2013 20:47:57 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 54ccbf19-296c-4299-b0fd-134d5658927f X-Archives-Hash: 656b2b97ae0c2adc2cba39d69f854be4 commit: fbe5409a3bebeee9c729a21e2c88a3f93c26e992 Author: Mike Frysinger gentoo org> AuthorDate: Wed Oct 16 18:41:02 2013 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Wed Oct 16 20:33:01 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=fbe5409a 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 65d81c6..4f158cd 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)