1 |
On Sun, 20 Mar 2016 21:11:41 -0700 |
2 |
Zac Medico <zmedico@g.o> wrote: |
3 |
|
4 |
> Fix localized_size to handle UnicodeDecodeError, which is necessary |
5 |
> if the locale data is corrupt or has an unexpected encoding. |
6 |
> |
7 |
> X-Gentoo-bug: 577862 |
8 |
> X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=577862 |
9 |
> --- |
10 |
> pym/portage/localization.py | 6 +++++- |
11 |
> 1 file changed, 5 insertions(+), 1 deletion(-) |
12 |
> |
13 |
> diff --git a/pym/portage/localization.py b/pym/portage/localization.py |
14 |
> index 2db4b7a..90202fb 100644 |
15 |
> --- a/pym/portage/localization.py |
16 |
> +++ b/pym/portage/localization.py |
17 |
> @@ -38,5 +38,9 @@ def localized_size(num_bytes): |
18 |
> |
19 |
> # always round up, so that small files don't end up as '0 |
20 |
> KiB' num_kib = math.ceil(num_bytes / 1024) |
21 |
> - formatted_num = locale.format('%d', num_kib, grouping=True) |
22 |
> + try: |
23 |
> + formatted_num = locale.format('%d', num_kib, |
24 |
> grouping=True) |
25 |
> + except UnicodeDecodeError: |
26 |
> + # failure to decode locale data |
27 |
> + formatted_num = str(num_kib) |
28 |
> return (_unicode_decode(formatted_num, |
29 |
> encoding=_encodings['stdio']) + ' KiB') |
30 |
|
31 |
|
32 |
looks good. Also if you haven't looked at the forum thread again. |
33 |
|
34 |
Portage did not fail when he set python 2.7 as the active one. So it |
35 |
is 3.4 only that is failing for him (just those 2 installed). |
36 |
|
37 |
-- |
38 |
Brian Dolbec <dolsen> |