From b72e032ea252757c4309516c865fafaf7354036b Mon Sep 17 00:00:00 2001 From: Paul Varner Date: Thu, 30 Jun 2016 15:39:24 -0500 Subject: 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)] -- cgit v1.2.3-65-gdbad