aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Varner <fuzzyray@gentoo.org>2015-11-24 13:07:33 -0600
committerPaul Varner <fuzzyray@gentoo.org>2015-11-24 13:07:33 -0600
commitc9a117bebeb04efcb731e47a12e79c4c8d065896 (patch)
tree6db392af53510002fce752a07b5c9d79daafddea /pym/gentoolkit/helpers.py
parentFix spelling error (diff)
downloadgentoolkit-c9a117bebeb04efcb731e47a12e79c4c8d065896.tar.gz
gentoolkit-c9a117bebeb04efcb731e47a12e79c4c8d065896.tar.bz2
gentoolkit-c9a117bebeb04efcb731e47a12e79c4c8d065896.zip
Change all open() calls to use Unicode.
We are using the following import from portage: from portage import _encodings, _unicode_decode, _unicode_encode A generalized call using the definitions from portage looks like: with open(_unicode_encode(path), encoding=_encodings['fs']) as open_file The portage code has been in place since 2013 and using the definitions from portage ensures we maintain compatibility if portage changes. All portage versions in the tree contain the above code.
Diffstat (limited to 'pym/gentoolkit/helpers.py')
-rw-r--r--pym/gentoolkit/helpers.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/pym/gentoolkit/helpers.py b/pym/gentoolkit/helpers.py
index 55fecdb..f9da6cd 100644
--- a/pym/gentoolkit/helpers.py
+++ b/pym/gentoolkit/helpers.py
@@ -27,11 +27,11 @@ __docformat__ = 'epytext'
import os
import re
-import codecs
from functools import partial
from itertools import chain
import portage
+from portage import _encodings, _unicode_decode, _unicode_encode
from gentoolkit import pprinter as pp
from gentoolkit import errors
@@ -194,8 +194,8 @@ class ChangeLog(object):
result = []
partial_entries = []
- with codecs.open(self.changelog_path, encoding="utf-8",
- errors="replace") as log:
+ with open(_unicode_encode(self.changelog_path),
+ encoding=_encodings['fs'], errors="replace") as log:
for line in log:
if line.startswith('#'):
continue
@@ -464,7 +464,7 @@ def get_bintree_cpvs(predicate=None):
def print_file(path):
"""Display the contents of a file."""
- with open(path, "rb") as open_file:
+ with open(_unicode_encode(path), encoding=_encodings['fs'], mode="rb") as open_file:
lines = open_file.read()
pp.uprint(lines.strip())