From 42dbc8067534ae2f8183a6bc69202fb08c81a4aa Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 20 Jul 2009 18:57:18 +0000 Subject: 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 --- pym/portage/util.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pym') 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: -- cgit v1.2.3-1-g7c22