From: Zac Medico Date: Sun, 5 Jul 2009 21:40:28 +0000 (-0000) Subject: Assume utf_8 encoding in alls reads/writes (unicode handling required for py3k). X-Git-Tag: v2.2_rc34~71 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7968394a681c49e60b7de397c5a61b165b8dc19e;p=portage.git Assume utf_8 encoding in alls reads/writes (unicode handling required for py3k). svn path=/main/trunk/; revision=13791 --- diff --git a/pym/portage/cache/flat_hash.py b/pym/portage/cache/flat_hash.py index ac1b7f190..71ddf6023 100644 --- a/pym/portage/cache/flat_hash.py +++ b/pym/portage/cache/flat_hash.py @@ -3,6 +3,7 @@ # License: GPL2 # $Id$ +import codecs from portage.cache import fs_template from portage.cache import cache_errors import errno, os, stat @@ -26,7 +27,7 @@ class database(fs_template.FsBased): def _getitem(self, cpv): fp = os.path.join(self.location, cpv) try: - myf = open(fp, "r") + myf = codecs.open(fp, mode='r', encoding='utf_8', errors='replace') try: d = self._parse_data(myf, cpv) if '_mtime_' not in d: @@ -54,12 +55,14 @@ class database(fs_template.FsBased): s = cpv.rfind("/") fp = os.path.join(self.location,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:])) try: - myf = open(fp, 'w') + myf = codecs.open(fp, mode='w', + encoding='utf_8', errors='replace') except (IOError, OSError), e: if errno.ENOENT == e.errno: try: self._ensure_dirs(cpv) - myf=open(fp,"w") + myf = codecs.open(fp, mode='w', + encoding='utf_8', errors='replace') except (OSError, IOError),e: raise cache_errors.CacheCorruption(cpv, e) else: