summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-08-04 07:02:57 +0000
committerZac Medico <zmedico@gentoo.org>2009-08-04 07:02:57 +0000
commitcea6cc051580eacbf5c4a1433c90d8bf1c68720f (patch)
treedc97b4ad7604e4bf61064a3f06c36e6795bb9e5e
parent729b7d573c13250ee981b6f957a47ce58e7bb2df (diff)
downloadportage-cea6cc051580eacbf5c4a1433c90d8bf1c68720f.tar.gz
portage-cea6cc051580eacbf5c4a1433c90d8bf1c68720f.tar.bz2
portage-cea6cc051580eacbf5c4a1433c90d8bf1c68720f.zip
Bug #280259 - Fix binarytree to always open the Packages file as unicode.
svn path=/main/trunk/; revision=13890
-rw-r--r--pym/portage/dbapi/bintree.py32
1 files changed, 7 insertions, 25 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 2b4dd1834..b1a78f36c 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -430,18 +430,8 @@ class binarytree(object):
dirs.remove("All")
dirs.sort()
dirs.insert(0, "All")
- pkgindex = self._new_pkgindex()
+ pkgindex = self._load_pkgindex()
pf_index = None
- try:
- f = open(self._pkgindex_file)
- except EnvironmentError:
- pass
- else:
- try:
- pkgindex.read(f)
- finally:
- f.close()
- del f
if not self._pkgindex_version_supported(pkgindex):
pkgindex = self._new_pkgindex()
header = pkgindex.header
@@ -647,7 +637,8 @@ class binarytree(object):
urldata[1] + urldata[2], "Packages")
pkgindex = self._new_pkgindex()
try:
- f = open(pkgindex_file)
+ f = codecs.open(pkgindex_file,
+ encoding='utf_8', errors='replace')
try:
pkgindex.read(f)
finally:
@@ -846,18 +837,8 @@ class binarytree(object):
self.getname(cpv).split(os.path.sep)[-2] == "All":
self._create_symlink(cpv)
created_symlink = True
- pkgindex = self._new_pkgindex()
- try:
- f = codecs.open(self._pkgindex_file,
- encoding='utf_8', errors='replace')
- except EnvironmentError:
- pass
- else:
- try:
- pkgindex.read(f)
- finally:
- f.close()
- del f
+ pkgindex = self._load_pkgindex()
+
if not self._pkgindex_version_supported(pkgindex):
pkgindex = self._new_pkgindex()
@@ -1098,7 +1079,8 @@ class binarytree(object):
def _load_pkgindex(self):
pkgindex = self._new_pkgindex()
try:
- f = open(self._pkgindex_file)
+ f = codecs.open(self._pkgindex_file,
+ encoding='utf8', errors='replace')
except EnvironmentError:
pass
else: