summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>2012-02-16 20:43:00 +0100
committerArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>2012-02-16 20:43:00 +0100
commitdec82cb8c449e833e4b9934d56927c2ba682b0d9 (patch)
treeae6545e095c16fa5c91021d9e827fabb12cd4187
parent9c664779a16f6cbca8a5ffe7f6b0c68572819723 (diff)
downloadportage-dec82cb8c449e833e4b9934d56927c2ba682b0d9.tar.gz
portage-dec82cb8c449e833e4b9934d56927c2ba682b0d9.tar.bz2
portage-dec82cb8c449e833e4b9934d56927c2ba682b0d9.zip
portage.update.fixdbentries(): Fix ResourceWarnings with Python 3.2.
-rw-r--r--pym/portage/update.py5
1 files changed, 3 insertions, 2 deletions
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)