From 729b7d573c13250ee981b6f957a47ce58e7bb2df Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 4 Aug 2009 06:45:46 +0000 Subject: [PATCH] Bug #280259 - Use codecs.open() when reading the Packages file inside binarytree.inject(), in order to avoid a UnicodeDecodeError when the file is later written as a unicode stream (via atomic_ofstream). svn path=/main/trunk/; revision=13889 --- pym/portage/dbapi/bintree.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 41da32d39..2b4dd1834 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -21,6 +21,7 @@ from portage.localization import _ from portage import dep_expand, listdir, _check_distfile, _movefile +import codecs import os, errno, stat import re from itertools import chain, izip @@ -847,7 +848,8 @@ class binarytree(object): created_symlink = True pkgindex = self._new_pkgindex() try: - f = open(self._pkgindex_file) + f = codecs.open(self._pkgindex_file, + encoding='utf_8', errors='replace') except EnvironmentError: pass else: -- 2.26.2