Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH v2] localization: properly decode formatted number for localized_size().
Date: Wed, 06 Aug 2014 16:54:04
Message-Id: 1407344062-6673-1-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] localization: properly decode formatted number for localized_size(). by "Michał Górny"
1 Fixes: https://bugs.gentoo.org/show_bug.cgi?id=519124
2 ---
3 pym/portage/localization.py | 5 +++--
4 1 file changed, 3 insertions(+), 2 deletions(-)
5
6 diff --git a/pym/portage/localization.py b/pym/portage/localization.py
7 index e4d87b6..7d30b59 100644
8 --- a/pym/portage/localization.py
9 +++ b/pym/portage/localization.py
10 @@ -5,7 +5,7 @@
11 import locale
12 import math
13
14 -from portage import _unicode_decode
15 +from portage import _encodings, _unicode_decode
16
17 # We define this to make the transition easier for us.
18 def _(mystr):
19 @@ -36,4 +36,5 @@ def localized_size(num_bytes):
20
21 # always round up, so that small files don't end up as '0 KiB'
22 num_kib = math.ceil(num_bytes / 1024)
23 - return locale.format('%d', num_kib, grouping=True) + ' KiB'
24 + formatted_num = locale.format('%d', num_kib, grouping=True)
25 + return (_unicode_decode(formatted_num, encoding=_encodings['stdio']) + ' KiB')
26 --
27 2.0.4

Replies