diff options
author | Paul Varner <fuzzyray@gentoo.org> | 2016-06-30 18:09:52 -0500 |
---|---|---|
committer | Paul Varner <fuzzyray@gentoo.org> | 2016-06-30 18:30:54 -0500 |
commit | 51f3cf18de49ca9dffc34053da53e62930be9fab (patch) | |
tree | 2357f76caec95597a9955d88526c262c29835b9d /pym/gentoolkit/equery/which.py | |
parent | equery: Change option --ignore-linguas to --ignore-l10n (diff) | |
download | gentoolkit-51f3cf18de49ca9dffc34053da53e62930be9fab.tar.gz gentoolkit-51f3cf18de49ca9dffc34053da53e62930be9fab.tar.bz2 gentoolkit-51f3cf18de49ca9dffc34053da53e62930be9fab.zip |
Change open function to use UTF-8 encoding for content.
Uses io.open for Python 2 and built-in open for Python 3
All data from files is treated as Unicode and this should fix
most UnicodeDecodeErrors.
Diffstat (limited to 'pym/gentoolkit/equery/which.py')
-rw-r--r-- | pym/gentoolkit/equery/which.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/pym/gentoolkit/equery/which.py b/pym/gentoolkit/equery/which.py index 0d30a8d..137e52a 100644 --- a/pym/gentoolkit/equery/which.py +++ b/pym/gentoolkit/equery/which.py @@ -18,6 +18,8 @@ __docformat__ = 'epytext' import os import sys +if sys.hexversion < 0x3000000: + from io import open from getopt import gnu_getopt, GetoptError @@ -62,7 +64,8 @@ def print_help(with_description=True): def print_ebuild(ebuild_path): """Output the ebuild to std_out""" - with open(_unicode_encode(ebuild_path, encoding=_encodings['fs'])) as f: + with open(_unicode_encode(ebuild_path, encoding=_encodings['fs']), + encoding=_encodings['content']) as f: lines = f.readlines() print("\n\n") print("".join(lines)) |