diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-12-08 21:38:56 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-12-08 21:38:56 +0000 |
commit | e9923790b9290ae44ba3a8dd7670c8d878d3d88d (patch) | |
tree | 33c0eb86ac6ffb9d6c39ae2cccbb46783b6ae971 | |
parent | 16f2a01e156f2742677e9950bcf931239790c753 (diff) | |
download | portage-e9923790b9290ae44ba3a8dd7670c8d878d3d88d.tar.gz portage-e9923790b9290ae44ba3a8dd7670c8d878d3d88d.tar.bz2 portage-e9923790b9290ae44ba3a8dd7670c8d878d3d88d.zip |
When reading the remote Packages file for --getbinpkg, use codecs.iterdecode
to decode the stream. Also, don't use finally to close the atomic_ofstream
when writing the file since we want it to abort if an exception is raised.
svn path=/main/trunk/; revision=14969
-rw-r--r-- | pym/portage/dbapi/bintree.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 4df2020b5..cd5d0b6eb 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -711,8 +711,10 @@ class binarytree(object): # protocols and requires the base url to have a trailing # slash, so join manually... f = urllib_request_urlopen(base_url.rstrip("/") + "/Packages") + f_dec = codecs.iterdecode(f, + _encodings['repo.content'], errors='replace') try: - rmt_idx.readHeader(f) + rmt_idx.readHeader(f_dec) remote_timestamp = rmt_idx.header.get("TIMESTAMP", None) if not remote_timestamp: # no timestamp in the header, something's wrong @@ -724,7 +726,7 @@ class binarytree(object): rmt_idx.header.get("VERSION"), noiselevel=-1) pkgindex = None elif local_timestamp != remote_timestamp: - rmt_idx.readBody(f) + rmt_idx.readBody(f_dec) pkgindex = rmt_idx finally: f.close() @@ -739,10 +741,8 @@ class binarytree(object): from portage.util import atomic_ofstream, ensure_dirs ensure_dirs(os.path.dirname(pkgindex_file)) f = atomic_ofstream(pkgindex_file) - try: - pkgindex.write(f) - finally: - f.close() + pkgindex.write(f) + f.close() if pkgindex: self._remotepkgs = {} for d in pkgindex.packages: |