commit:     269aa06166e36a56219c13258cc53f0fa6e18609
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 12 18:21:16 2014 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Aug 12 18:25:50 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=269aa061

--sync: Decode getaddrinfo() errors properly

Fixes UnicodeDecodeError in Python 2 with getaddrinfo() error messages
that contain non-ASCII characters, e.g. in pl_PL.UTF-8 locale.

Reviewed-by: Alexander Berntsen <bernalex <AT> gentoo.org>
Reviewed-by: Brian Dolbec <dolsen <AT> gentoo.org>

---
 pym/_emerge/actions.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index e482744..66e18a4 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -2345,7 +2345,8 @@ def _sync_repo(emerge_config, repo):
                                family, socket.SOCK_STREAM))
                except socket.error as e:
                        writemsg_level(
-                               "!!! getaddrinfo failed for '%s': %s\n" % 
(hostname, e),
+                               "!!! getaddrinfo failed for '%s': %s\n" % 
(hostname,
+                                       _unicode_decode(e.strerror, 
encoding=_encodings['stdio'])),
                                noiselevel=-1, level=logging.ERROR)
 
                if addrinfos:

Reply via email to