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 C39CC58973 for ; Tue, 2 Feb 2016 01:33:07 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4914F21C049; Tue, 2 Feb 2016 01:33:06 +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 DB06121C049 for ; Tue, 2 Feb 2016 01:33:05 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EC3ED340DF0 for ; Tue, 2 Feb 2016 01:33:04 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 29D848E6 for ; Tue, 2 Feb 2016 01:33: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: <1454376732.1929e2bdab686004697c3d0fd999a563db43349c.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/UserQuery.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 1929e2bdab686004697c3d0fd999a563db43349c X-VCS-Branch: master Date: Tue, 2 Feb 2016 01:33: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: 15cd2670-709f-4f19-8f33-fe3e59802c7b X-Archives-Hash: d25af9eaa20f486a35031eca6b7be342 commit: 1929e2bdab686004697c3d0fd999a563db43349c Author: Zac Medico gentoo org> AuthorDate: Mon Feb 1 17:36:46 2016 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue Feb 2 01:32:12 2016 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=1929e2bd UserQuery: handle unicode (bug 573386) Handle UnicodeDecodeError from the input function in python3, and from comparisons with unicode literals in python2. X-Gentoo-Bug: 573386 X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=573386 Acked-by: Brian Dolbec gentoo.org> pym/_emerge/UserQuery.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pym/_emerge/UserQuery.py b/pym/_emerge/UserQuery.py index c866a0d..8096d1b 100644 --- a/pym/_emerge/UserQuery.py +++ b/pym/_emerge/UserQuery.py @@ -1,11 +1,12 @@ -# Copyright 1999-2014 Gentoo Foundation +# Copyright 1999-2016 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -from __future__ import print_function +from __future__ import print_function, unicode_literals import signal import sys +from portage import _unicode_decode from portage.output import bold, create_color_func @@ -47,17 +48,23 @@ class UserQuery(object): elif colours is None: colours=[bold] colours=(colours*len(responses))[:len(responses)] + responses = [_unicode_decode(x) for x in responses] if "--alert" in self.myopts: prompt = '\a' + prompt print(bold(prompt), end=' ') try: while True: if sys.hexversion >= 0x3000000: - response=input("["+"/".join([colours[i](responses[i]) - for i in range(len(responses))])+"] ") + try: + response = input("[%s] " % + "/".join([colours[i](responses[i]) + for i in range(len(responses))])) + except UnicodeDecodeError: + response = _unicode_decode(response.object).rstrip('\n') else: response=raw_input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ") + response = _unicode_decode(response) if response or not enter_invalid: for key in responses: # An empty response will match the