commit:     b72e032ea252757c4309516c865fafaf7354036b
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 30 20:39:24 2016 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Thu Jun 30 20:39:24 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=b72e032e

equery: Fix UnicodeDecodeError in python2.7

This fix explicitly decodes the content of the USE description files as
UTF-8. This fixes the UnicodeDecodeError in Python 2.7. Tested with a
POSIX locale with Python 2.7, 3.4 and 3.5.

X-Gentoo-bug: 587606
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=587606

 pym/gentoolkit/equery/uses.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pym/gentoolkit/equery/uses.py b/pym/gentoolkit/equery/uses.py
index 79ed00f..adf8b6c 100644
--- a/pym/gentoolkit/equery/uses.py
+++ b/pym/gentoolkit/equery/uses.py
@@ -138,6 +138,7 @@ def get_global_useflags():
                path = os.path.join(settings["PORTDIR"], 'profiles', 'use.desc')
                with open(_unicode_encode(path, encoding=_encodings['fs'])) as 
open_file:
                        for line in open_file:
+                               line = _unicode_decode(line)
                                if line.startswith('#'):
                                        continue
                                # Ex. of fields: ['syslog', 'Enables support 
for syslog\n']
@@ -158,6 +159,7 @@ def get_global_useflags():
                try:
                        with open(_unicode_encode(path, 
encoding=_encodings['fs'])) as open_file:
                                for line in open_file:
+                                       line = _unicode_decode(line)
                                        if line.startswith('#'):
                                                continue
                                        fields = [field.strip() for field in 
line.split(" - ", 1)]

Reply via email to