summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-07-05 21:40:28 +0000
committerZac Medico <zmedico@gentoo.org>2009-07-05 21:40:28 +0000
commit7968394a681c49e60b7de397c5a61b165b8dc19e (patch)
treed947bda208acfa880deb4c7996bf218985c372c1
parent0da8a2be6c9673adbb966af720a52eab2e880507 (diff)
downloadportage-7968394a681c49e60b7de397c5a61b165b8dc19e.tar.gz
portage-7968394a681c49e60b7de397c5a61b165b8dc19e.tar.bz2
portage-7968394a681c49e60b7de397c5a61b165b8dc19e.zip
Assume utf_8 encoding in alls reads/writes (unicode handling required for py3k).
svn path=/main/trunk/; revision=13791
-rw-r--r--pym/portage/cache/flat_hash.py9
1 files changed, 6 insertions, 3 deletions
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: