Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH v2] bintree.py: fix str() calls for Python 2 (532784)
Date: Wed, 17 Dec 2014 21:43:26
Message-Id: 20141217134249.07963170.dolsen@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH v2] bintree.py: fix str() calls for Python 2 (532784) by Zac Medico
1 On Wed, 17 Dec 2014 09:59:22 -0800
2 Zac Medico <zmedico@g.o> wrote:
3
4 > Avoid a UnicodeDecodeError raised when str(e) converts an exception
5 > to bytes with Python 2. Since this file has unicode_literals enabled,
6 > use literal unicode format strings to format messages for unicode
7 > exceptions. However, with Python 2, an EnvironmentError exception
8 > may contain either bytes or unicode, so use _unicode(errors="replace")
9 > to ensure safety for EnvironmentError with all locales.
10 >
11 > Also, convert remaining str() calls to use _unicode() for uniform
12 > behavior regardless of python version.
13 >
14 > X-Gentoo-Bug: 532784
15 > X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=532784
16 > ---
17 > PATCH v2 replaces the _unicode_decode call with
18 > _unicode(errors="replace"), which is required in order to force the
19 > EnvironmentError object to be converted to a unicode string.
20 >
21
22 Yup, LGTM
23
24
25 --
26 Brian Dolbec <dolsen>