commit:     c91509d823c27fdb1527c61f77c959b305170915
Author:     zakalwe <sc.contact <AT> gmail <DOT> com>
AuthorDate: Tue Feb 21 03:09:11 2017 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Feb 21 03:18:51 2017 +0000
URL:        https://gitweb.gentoo.org/proj/mirrorselect.git/commit/?id=c91509d8

main.py: Fix Bytes error in hosts list bug 610016

The code was only checking the first host which was not a bytes instance
in that case.  This resulted in the remaining host entries to not be decoded.

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

 mirrorselect/main.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mirrorselect/main.py b/mirrorselect/main.py
index d17a4f1..30345cc 100755
--- a/mirrorselect/main.py
+++ b/mirrorselect/main.py
@@ -108,8 +108,9 @@ class MirrorSelect(object):
                else:
                        var = 'GENTOO_MIRRORS'
 
-               if hasattr(hosts[0], 'decode'):
-                       hosts = [x.decode('utf-8') for x in hosts]
+               for i in range(0, len(hosts)):
+                       if isinstance(hosts[i], 'bytes'):
+                               hosts[i] = hosts[i].decode('utf-8')
 
                if var == "sync-uri" and out:
                        mirror_string = '%s = %s' % (var, ' '.join(hosts))

Reply via email to