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 D93AE1389F5 for ; Thu, 2 Apr 2015 19:15:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C3A04E0794; Thu, 2 Apr 2015 19:15:09 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 64AC5E0794 for ; Thu, 2 Apr 2015 19:15:09 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3A21C3404B1 for ; Thu, 2 Apr 2015 19:15:07 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A0E1E15139 for ; Thu, 2 Apr 2015 19:15:03 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1427930092.f9a2d7025e22f5e1711f39c4740a020f6f0d2c8f.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/, bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/dispatch-conf pym/portage/dispatch_conf.py X-VCS-Directories: bin/ pym/portage/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: f9a2d7025e22f5e1711f39c4740a020f6f0d2c8f X-VCS-Branch: master Date: Thu, 2 Apr 2015 19:15:03 +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: 8a53d217-0d73-4979-97f8-c8514579abfd X-Archives-Hash: 3098e2d9042d22bc0be7c53d52f7a362 commit: f9a2d7025e22f5e1711f39c4740a020f6f0d2c8f Author: Zac Medico gentoo org> AuthorDate: Wed Apr 1 22:27:42 2015 +0000 Commit: Zac Medico gentoo org> CommitDate: Wed Apr 1 23:14:52 2015 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f9a2d702 dispatch-conf: fix unicode handling (bug 545270) This avoids UnicodeDecodeError problems by using UTF-8 encoding regardless of the locale. X-Gentoo-Bug: 545270 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=545270 bin/dispatch-conf | 9 +++++---- pym/portage/dispatch_conf.py | 4 +--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/bin/dispatch-conf b/bin/dispatch-conf index b679910..678a66d 100755 --- a/bin/dispatch-conf +++ b/bin/dispatch-conf @@ -11,12 +11,11 @@ # dialog menus # -from __future__ import print_function +from __future__ import print_function, unicode_literals import atexit import io import re -import shutil import sys from stat import ST_GID, ST_MODE, ST_UID @@ -27,7 +26,7 @@ if osp.isfile(osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), ".porta sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) import portage portage._internal_caller = True -from portage import os +from portage import os, shutil from portage import _encodings, _unicode_decode from portage.dispatch_conf import diffstatusoutput, diff_mixed_wrapper from portage.process import find_binary, spawn @@ -403,7 +402,9 @@ class dispatch: newconfigs.sort () for nconf in newconfigs: - nconf = nconf.rstrip () + # Use strict mode here, because we want to know if it fails, + # and portage only merges files with valid UTF-8 encoding. + nconf = _unicode_decode(nconf, errors='strict').rstrip() conf = re.sub (r'\._cfg\d+_', '', nconf) dirname = os.path.dirname(nconf) conf_map = { diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py index 790eacb..98939fd 100644 --- a/pym/portage/dispatch_conf.py +++ b/pym/portage/dispatch_conf.py @@ -10,15 +10,13 @@ from __future__ import print_function, unicode_literals import io import functools -import os -import shutil import stat import subprocess import sys import tempfile import portage -from portage import _encodings +from portage import _encodings, os, shutil from portage.env.loaders import KeyValuePairFileLoader from portage.localization import _ from portage.util import shlex_split, varexpand