summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/cache/flat_hash.py19
-rw-r--r--pym/portage/cache/flat_list.py19
-rw-r--r--pym/portage/cache/metadata.py21
3 files changed, 39 insertions, 20 deletions
diff --git a/pym/portage/cache/flat_hash.py b/pym/portage/cache/flat_hash.py
index 2467f6800..259be4108 100644
--- a/pym/portage/cache/flat_hash.py
+++ b/pym/portage/cache/flat_hash.py
@@ -9,6 +9,7 @@ from portage.cache import cache_errors
import errno
import stat
from portage import os
+from portage import _encodings
from portage import _unicode_encode
class database(fs_template.FsBased):
@@ -29,8 +30,10 @@ class database(fs_template.FsBased):
def _getitem(self, cpv):
fp = os.path.join(self.location, cpv)
try:
- myf = codecs.open(_unicode_encode(fp),
- mode='r', encoding='utf_8', errors='replace')
+ myf = codecs.open(_unicode_encode(fp,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='r', encoding=_encodings['repo.content'],
+ errors='replace')
try:
d = self._parse_data(myf.readlines(), cpv)
if '_mtime_' not in d:
@@ -58,14 +61,18 @@ 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 = codecs.open(_unicode_encode(fp), mode='w',
- encoding='utf_8', errors='replace')
+ myf = codecs.open(_unicode_encode(fp,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='w', encoding=_encodings['repo.content'],
+ errors='backslashreplace')
except (IOError, OSError), e:
if errno.ENOENT == e.errno:
try:
self._ensure_dirs(cpv)
- myf = codecs.open(_unicode_encode(fp), mode='w',
- encoding='utf_8', errors='replace')
+ myf = codecs.open(_unicode_encode(fp,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='w', encoding=_encodings['repo.content'],
+ errors='backslashreplace')
except (OSError, IOError),e:
raise cache_errors.CacheCorruption(cpv, e)
else:
diff --git a/pym/portage/cache/flat_list.py b/pym/portage/cache/flat_list.py
index 9906dd22d..1d4dbd28f 100644
--- a/pym/portage/cache/flat_list.py
+++ b/pym/portage/cache/flat_list.py
@@ -1,6 +1,7 @@
from portage.cache import fs_template
from portage.cache import cache_errors
from portage import os
+from portage import _encodings
from portage import _unicode_encode
import codecs
import errno
@@ -31,8 +32,10 @@ class database(fs_template.FsBased):
def _getitem(self, cpv):
d = {}
try:
- myf = codecs.open(_unicode_encode(os.path.join(self._base, cpv)),
- mode='r', encoding='utf_8', errors='replace')
+ myf = codecs.open(_unicode_encode(os.path.join(self._base, cpv),
+ encoding=_encodings['fs'], errors='strict'),
+ mode='r', encoding=_encodings['repo.content'],
+ errors='replace')
for k,v in zip(self.auxdbkey_order, myf):
d[k] = v.rstrip("\n")
except (OSError, IOError),e:
@@ -53,14 +56,18 @@ class database(fs_template.FsBased):
s = cpv.rfind("/")
fp=os.path.join(self._base,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:]))
try:
- myf = codecs.open(_unicode_encode(fp), mode='w',
- encoding='utf_8', errors='replace')
+ myf = codecs.open(_unicode_encode(fp,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='w', encoding=_encodings['repo.content'],
+ errors='backslashreplace')
except (OSError, IOError), e:
if errno.ENOENT == e.errno:
try:
self._ensure_dirs(cpv)
- myf = codecs.open(_unicode_encode(fp), mode='w',
- encoding='utf_8', errors='replace')
+ myf = codecs.open(_unicode_encode(fp,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='w', encoding=_encodings['repo.content'],
+ errors='backslashreplace')
except (OSError, IOError),e:
raise cache_errors.CacheCorruption(cpv, e)
else:
diff --git a/pym/portage/cache/metadata.py b/pym/portage/cache/metadata.py
index e91ed68d2..ff1227bdb 100644
--- a/pym/portage/cache/metadata.py
+++ b/pym/portage/cache/metadata.py
@@ -6,6 +6,7 @@
import errno
import re
from portage import os
+from portage import _encodings
from portage import _unicode_encode
from portage.cache import cache_errors, flat_hash
import portage.eclass_cache
@@ -80,16 +81,18 @@ class database(flat_hash.database):
new_content = []
for k in self.auxdbkey_order:
- new_content.append(values.get(k, u''))
- new_content.append(u'\n')
+ new_content.append(values.get(k, ''))
+ new_content.append('\n')
for i in xrange(magic_line_count - len(self.auxdbkey_order)):
- new_content.append(u'\n')
- new_content = u''.join(new_content)
- new_content = _unicode_encode(new_content)
+ new_content.append('\n')
+ new_content = ''.join(new_content)
+ new_content = _unicode_encode(new_content,
+ _encodings['repo.content'], errors='backslashreplace')
new_fp = os.path.join(self.location, cpv)
try:
- f = open(_unicode_encode(new_fp), 'rb')
+ f = open(_unicode_encode(new_fp,
+ encoding=_encodings['fs'], errors='strict'), 'rb')
except EnvironmentError:
pass
else:
@@ -117,12 +120,14 @@ class database(flat_hash.database):
fp = os.path.join(self.location,cpv[:s],
".update.%i.%s" % (os.getpid(), cpv[s+1:]))
try:
- myf = open(_unicode_encode(fp), 'wb')
+ myf = open(_unicode_encode(fp,
+ encoding=_encodings['fs'], errors='strict'), 'wb')
except EnvironmentError, e:
if errno.ENOENT == e.errno:
try:
self._ensure_dirs(cpv)
- myf = open(_unicode_encode(fp), 'wb')
+ myf = open(_unicode_encode(fp,
+ encoding=_encodings['fs'], errors='strict'), 'wb')
except EnvironmentError, e:
raise cache_errors.CacheCorruption(cpv, e)
else: