From: Zac Medico Date: Tue, 4 Aug 2009 06:45:46 +0000 (-0000) Subject: Bug #280259 - Use codecs.open() when reading the Packages file inside X-Git-Tag: v2.2_rc36~25 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=729b7d573c13250ee981b6f957a47ce58e7bb2df;p=portage.git 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 --- 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: