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 65C24138262 for ; Wed, 18 May 2016 16:42:14 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 26A5D14241; Wed, 18 May 2016 16:42:12 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id CCD2914241 for ; Wed, 18 May 2016 16:42:11 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3F527340CDF for ; Wed, 18 May 2016 16:42:10 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B020B964 for ; Wed, 18 May 2016 16:42:08 +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: <1463589682.33c8d30cc10cb11cb098d4dfe92f7187b20eefaf.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/localization.py X-VCS-Directories: pym/portage/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 33c8d30cc10cb11cb098d4dfe92f7187b20eefaf X-VCS-Branch: master Date: Wed, 18 May 2016 16:42:08 +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: 4109727b-daa9-4b73-9cce-0092f88dfeab X-Archives-Hash: 5ee0007c2d111eee5b91df6198faf722 commit: 33c8d30cc10cb11cb098d4dfe92f7187b20eefaf Author: Zac Medico gentoo org> AuthorDate: Mon Mar 21 04:09:54 2016 +0000 Commit: Zac Medico gentoo org> CommitDate: Wed May 18 16:41:22 2016 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=33c8d30c localized_size: handle UnicodeDecodeError (bug 577862) Fix localized_size to handle UnicodeDecodeError, which is necessary if the locale data is corrupt or has an unexpected encoding. X-Gentoo-bug: 577862 X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=577862 Acked-by: Brian Dolbec gentoo.org> pym/portage/localization.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pym/portage/localization.py b/pym/portage/localization.py index 2db4b7a..90202fb 100644 --- a/pym/portage/localization.py +++ b/pym/portage/localization.py @@ -38,5 +38,9 @@ def localized_size(num_bytes): # always round up, so that small files don't end up as '0 KiB' num_kib = math.ceil(num_bytes / 1024) - formatted_num = locale.format('%d', num_kib, grouping=True) + try: + formatted_num = locale.format('%d', num_kib, grouping=True) + except UnicodeDecodeError: + # failure to decode locale data + formatted_num = str(num_kib) return (_unicode_decode(formatted_num, encoding=_encodings['stdio']) + ' KiB')