summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-07-20 18:57:18 +0000
committerZac Medico <zmedico@gentoo.org>2009-07-20 18:57:18 +0000
commit42dbc8067534ae2f8183a6bc69202fb08c81a4aa (patch)
tree19ce9c203dd8a7f3b21cb6834ed2fe1449945c41 /pym
parentdd0bd38bd9648387b6cae69540d9bfd2cac87d75 (diff)
downloadportage-42dbc8067534ae2f8183a6bc69202fb08c81a4aa.tar.gz
portage-42dbc8067534ae2f8183a6bc69202fb08c81a4aa.tar.bz2
portage-42dbc8067534ae2f8183a6bc69202fb08c81a4aa.zip
In grablines(), specify encoding=sys.getdefaultencoding() in the codecs.open()
parameters, since otherwise readlines doesn't return unicode (at least in some cases, observed with python-2.6.2). Also, fix grabfile() to return unicode when it normalizes whitespace. svn path=/main/trunk/; revision=13837
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/util.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/pym/portage/util.py b/pym/portage/util.py
index 4ccd512ae..6d9a23cd1 100644
--- a/pym/portage/util.py
+++ b/pym/portage/util.py
@@ -103,7 +103,7 @@ def grabfile(myfilename, compat_level=0, recursive=0):
for x in mylines:
#the split/join thing removes leading and trailing whitespace, and converts any whitespace in the line
#into single spaces.
- myline=" ".join(x.split())
+ myline = u' '.join(x.split())
if not len(myline):
continue
if myline[0]=="#":
@@ -317,7 +317,8 @@ def grablines(myfilename,recursive=0):
os.path.join(myfilename, f), recursive))
else:
try:
- myfile = codecs.open(myfilename, mode='r', errors='replace')
+ myfile = codecs.open(myfilename, mode='r',
+ encoding=sys.getdefaultencoding(), errors='replace')
mylines = myfile.readlines()
myfile.close()
except IOError, e: