summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-07-04 19:25:42 +0000
committerZac Medico <zmedico@gentoo.org>2009-07-04 19:25:42 +0000
commitc53137420b0a64da9add50e66a43b7bec21343b9 (patch)
tree0894c8270d647358b16532dc992e706ad6b6d76c /pym
parent137fc96206a58ba80533e280583aa34e31b129fc (diff)
downloadportage-c53137420b0a64da9add50e66a43b7bec21343b9.tar.gz
portage-c53137420b0a64da9add50e66a43b7bec21343b9.tar.bz2
portage-c53137420b0a64da9add50e66a43b7bec21343b9.zip
Make getconfig() use codecs.option() for py3k compatible unicode handling.
svn path=/main/trunk/; revision=13780
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/util.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/pym/portage/util.py b/pym/portage/util.py
index d57b1bc35..1da4b4ba2 100644
--- a/pym/portage/util.py
+++ b/pym/portage/util.py
@@ -12,6 +12,7 @@ __all__ = ['apply_permissions', 'apply_recursive_permissions',
'unique_array', 'varexpand', 'write_atomic', 'writedict', 'writemsg',
'writemsg_level', 'writemsg_stdout']
+import codecs
import os
import errno
import logging
@@ -366,7 +367,10 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
# Workaround for avoiding a silent error in shlex that
# is triggered by a source statement at the end of the file without a
# trailing newline after the source statement
- f = StringIO("\n".join(open(mycfg, 'r').readlines()) + "\n")
+ content = codecs.open(mycfg, mode='r', errors='replace').read()
+ if content[-1] != u'\n':
+ content += u'\n'
+ f = StringIO(content)
except IOError, e:
if e.errno == PermissionDenied.errno:
raise PermissionDenied(mycfg)