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 7B3541381F3 for ; Wed, 2 Oct 2013 10:40:02 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B4696E0C15; Wed, 2 Oct 2013 10:39:41 +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 4AB8EE0C12 for ; Wed, 2 Oct 2013 10:39:41 +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 2DF3433EDD8 for ; Wed, 2 Oct 2013 10:39:40 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id D145CE5308 for ; Wed, 2 Oct 2013 10:39:38 +0000 (UTC) From: "Arfrever Frehtes Taifersar Arahesis" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arfrever Frehtes Taifersar Arahesis" Message-ID: <1380710209.5924b7afae7c731abc24a0e16fcd103e680e3e5b.arfrever@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/env/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/env/loaders.py X-VCS-Directories: pym/portage/env/ X-VCS-Committer: arfrever X-VCS-Committer-Name: Arfrever Frehtes Taifersar Arahesis X-VCS-Revision: 5924b7afae7c731abc24a0e16fcd103e680e3e5b X-VCS-Branch: master Date: Wed, 2 Oct 2013 10:39:38 +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: 0337786d-6997-4085-93e7-c6312ce7ddbb X-Archives-Hash: 94a464fd3f0c866e1a73910a370e2f26 commit: 5924b7afae7c731abc24a0e16fcd103e680e3e5b Author: Arfrever Frehtes Taifersar Arahesis Apache Org> AuthorDate: Wed Oct 2 10:36:49 2013 +0000 Commit: Arfrever Frehtes Taifersar Arahesis Apache Org> CommitDate: Wed Oct 2 10:36:49 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5924b7af Bug #418475: Handle PermissionError caused by unreadable /etc/portage/modules. --- pym/portage/env/loaders.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/pym/portage/env/loaders.py b/pym/portage/env/loaders.py index 372bc12..f869884 100644 --- a/pym/portage/env/loaders.py +++ b/pym/portage/env/loaders.py @@ -1,10 +1,14 @@ # config.py -- Portage Config -# Copyright 2007-2011 Gentoo Foundation +# Copyright 2007-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import errno import io import stat +import portage +portage.proxy.lazyimport.lazyimport(globals(), + 'portage.util:writemsg', +) from portage import os from portage import _encodings from portage import _unicode_decode @@ -149,17 +153,21 @@ class FileLoader(DataLoader): func = self.lineParser for fn in RecursiveFileLoader(self.fname): try: - f = io.open(_unicode_encode(fn, + with io.open(_unicode_encode(fn, encoding=_encodings['fs'], errors='strict'), mode='r', - encoding=_encodings['content'], errors='replace') + encoding=_encodings['content'], errors='replace') as f: + lines = f.readlines() except EnvironmentError as e: - if e.errno not in (errno.ENOENT, errno.ESTALE): + if e.errno == errno.EACCES: + writemsg(_("Permission denied: '%s'\n") % fn, noiselevel=-1) + del e + elif e.errno in (errno.ENOENT, errno.ESTALE): + del e + else: raise - del e - continue - for line_num, line in enumerate(f): - func(line, line_num, data, errors) - f.close() + else: + for line_num, line in enumerate(lines): + func(line, line_num, data, errors) return (data, errors) def lineParser(self, line, line_num, data, errors):