diff options
author | Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org> | 2012-02-17 22:33:13 +0100 |
---|---|---|
committer | Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org> | 2012-02-17 22:33:13 +0100 |
commit | 28ae573f075d718389146f78f293a2120ce65157 (patch) | |
tree | 97dff3438caf91fe11c464d2869f6cd99f133440 | |
parent | 4a858889202448e93cb43ec2559e9f66c30b09c9 (diff) | |
download | portage-28ae573f075d718389146f78f293a2120ce65157.tar.gz portage-28ae573f075d718389146f78f293a2120ce65157.tar.bz2 portage-28ae573f075d718389146f78f293a2120ce65157.zip |
portage.package.ebuild.fetch.fetch(): Fix ResourceWarning with Python 3.2.
-rw-r--r-- | pym/portage/package/ebuild/fetch.py | 19 |
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: |