1 |
On Sun, 3 May 2015 21:52:33 -0700 |
2 |
Zac Medico <zmedico@g.o> wrote: |
3 |
|
4 |
> Since commit 4496ee37d6fa327ada635c67500e82f830141a9e, binhost |
5 |
> connection errors result in a TypeError. Fix it to call the unicode |
6 |
> function correctly (with only a single argument). Also, handle |
7 |
> a possible UnicodeDecodeError. |
8 |
> |
9 |
> Fixes: 4496ee37d6fa ("bintree.py: fix str() calls for Python 2 |
10 |
> (532784)") X-Gentoo-Bug: 532784 |
11 |
> X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=532784 |
12 |
> --- |
13 |
> pym/portage/dbapi/bintree.py | 8 ++++++-- |
14 |
> 1 file changed, 6 insertions(+), 2 deletions(-) |
15 |
> |
16 |
> diff --git a/pym/portage/dbapi/bintree.py |
17 |
> b/pym/portage/dbapi/bintree.py index b37f388..4043016 100644 |
18 |
> --- a/pym/portage/dbapi/bintree.py |
19 |
> +++ b/pym/portage/dbapi/bintree.py |
20 |
> @@ -961,8 +961,12 @@ class binarytree(object): |
21 |
> # With Python 2, the |
22 |
> EnvironmentError message may # contain bytes or unicode, so use |
23 |
> _unicode to ensure # safety with all locales (bug #532784). |
24 |
> - writemsg("!!! %s\n\n" % _unicode(e, |
25 |
> - _encodings["stdio"], |
26 |
> errors="replace")) |
27 |
> + try: |
28 |
> + error_msg = _unicode(e) |
29 |
> + except UnicodeDecodeError as uerror: |
30 |
> + error_msg = |
31 |
> _unicode(uerror.object, |
32 |
> + encoding='utf_8', |
33 |
> errors='replace') |
34 |
> + writemsg("!!! %s\n\n" % error_msg) |
35 |
> del e |
36 |
> pkgindex = None |
37 |
> if proc is not None: |
38 |
|
39 |
|
40 |
Isn't this backwards from what was reported. It generated a |
41 |
UnicodeDecodeError when using additional args to unicode(). It needed |
42 |
to convert it to string so errors= needed to not be passed in. |
43 |
|
44 |
-- |
45 |
Brian Dolbec <dolsen> |