From: Arfrever Frehtes Taifersar Arahesis Date: Thu, 16 Feb 2012 19:43:00 +0000 (+0100) Subject: portage.update.fixdbentries(): Fix ResourceWarnings with Python 3.2. X-Git-Tag: v2.2.0_alpha87~23 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dec82cb8c449e833e4b9934d56927c2ba682b0d9;p=portage.git portage.update.fixdbentries(): Fix ResourceWarnings with Python 3.2. --- diff --git a/pym/portage/update.py b/pym/portage/update.py index 6d13dfc85..34e466366 100644 --- a/pym/portage/update.py +++ b/pym/portage/update.py @@ -86,10 +86,11 @@ def fixdbentries(update_iter, dbdir): mydata = {} for myfile in [f for f in os.listdir(dbdir) if f not in ignored_dbentries]: file_path = os.path.join(dbdir, myfile) - mydata[myfile] = io.open(_unicode_encode(file_path, + with io.open(_unicode_encode(file_path, encoding=_encodings['fs'], errors='strict'), mode='r', encoding=_encodings['repo.content'], - errors='replace').read() + errors='replace') as f: + mydata[myfile] = f.read() updated_items = update_dbentries(update_iter, mydata) for myfile, mycontent in updated_items.items(): file_path = os.path.join(dbdir, myfile)