aboutsummaryrefslogtreecommitdiff
path: root/pym
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>2012-02-17 22:33:13 +0100
committerArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>2012-02-17 22:33:13 +0100
commit28ae573f075d718389146f78f293a2120ce65157 (patch)
tree97dff3438caf91fe11c464d2869f6cd99f133440 /pym
parentEventLoop.iteration: run timeouts last (diff)
downloadportage-28ae573f075d718389146f78f293a2120ce65157.tar.gz
portage-28ae573f075d718389146f78f293a2120ce65157.tar.bz2
portage-28ae573f075d718389146f78f293a2120ce65157.zip
portage.package.ebuild.fetch.fetch(): Fix ResourceWarning with Python 3.2.
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/package/ebuild/fetch.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py
index 8c20b7186..022d3e89a 100644
--- a/pym/portage/package/ebuild/fetch.py
+++ b/pym/portage/package/ebuild/fetch.py
@@ -1028,18 +1028,19 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0,
# Fetch failed... Try the next one... Kill 404 files though.
if (mystat[stat.ST_SIZE]<100000) and (len(myfile)>4) and not ((myfile[-5:]==".html") or (myfile[-4:]==".htm")):
html404=re.compile("<title>.*(not found|404).*</title>",re.I|re.M)
- if html404.search(io.open(
+ with io.open(
_unicode_encode(myfile_path,
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['content'], errors='replace'
- ).read()):
- try:
- os.unlink(mysettings["DISTDIR"]+"/"+myfile)
- writemsg(_(">>> Deleting invalid distfile. (Improper 404 redirect from server.)\n"))
- fetched = 0
- continue
- except (IOError, OSError):
- pass
+ ) as f:
+ if html404.search(f.read()):
+ try:
+ os.unlink(mysettings["DISTDIR"]+"/"+myfile)
+ writemsg(_(">>> Deleting invalid distfile. (Improper 404 redirect from server.)\n"))
+ fetched = 0
+ continue
+ except (IOError, OSError):
+ pass
fetched = 1
continue
if True: