diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-08-14 23:44:57 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-08-14 23:44:57 +0000 |
commit | 8bb6daebe7a8b394e360cceb1655e9634f339904 (patch) | |
tree | bc74807e8cc2320671a91ed546f137d4a08556a6 | |
parent | 71de16243fbe4effec21d2c6e7801011b7c04612 (diff) | |
download | portage-8bb6daebe7a8b394e360cceb1655e9634f339904.tar.gz portage-8bb6daebe7a8b394e360cceb1655e9634f339904.tar.bz2 portage-8bb6daebe7a8b394e360cceb1655e9634f339904.zip |
Use portage._fs_encoding where appropriage, and use strict handling for
errors.
svn path=/main/trunk/; revision=14055
-rw-r--r-- | pym/portage/manifest.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py index e411be8c1..403e01115 100644 --- a/pym/portage/manifest.py +++ b/pym/portage/manifest.py @@ -12,6 +12,7 @@ portage.proxy.lazyimport.lazyimport(globals(), ) from portage import os +from portage import _fs_encoding from portage import _unicode_decode from portage import _unicode_encode from portage.exception import DigestException, FileNotFound, \ @@ -141,7 +142,8 @@ class Manifest(object): """Parse a manifest. If myhashdict is given then data will be added too it. Otherwise, a new dict will be created and returned.""" try: - fd = codecs.open(_unicode_encode(file_path), mode='r', + fd = codecs.open(_unicode_encode(file_path, + encoding=_fs_encoding, errors='strict'), mode='r', encoding='utf_8', errors='replace') if myhashdict is None: myhashdict = {} @@ -228,7 +230,8 @@ class Manifest(object): update_manifest = True if not force: try: - f = codecs.open(_unicode_encode(self.getFullname()), + f = codecs.open(_unicode_encode(self.getFullname(), + encoding=_fs_encoding, errors='strict'), mode='r', encoding='utf_8', errors='replace') oldentries = list(self._parseManifestLines(f)) f.close() @@ -320,7 +323,11 @@ class Manifest(object): for pkgdir, pkgdir_dirs, pkgdir_files in os.walk(pkgdir): break for f in pkgdir_files: - f = _unicode_decode(f) + try: + f = _unicode_decode(f, + encoding=_fs_encoding, errors='strict') + except UnicodeDecodeError: + continue if f[:1] == ".": continue pf = None @@ -351,6 +358,11 @@ class Manifest(object): cut_len = len(os.path.join(pkgdir, "files") + os.sep) for parentdir, dirs, files in os.walk(os.path.join(pkgdir, "files")): for f in files: + try: + f = _unicode_decode(f, + encoding=_fs_encoding, errors='strict') + except UnicodeDecodeError: + continue full_path = os.path.join(parentdir, f) recursive_files.append(full_path[cut_len:]) for f in recursive_files: @@ -508,7 +520,8 @@ class Manifest(object): mfname = self.getFullname() if not os.path.exists(mfname): return rVal - myfile = codecs.open(_unicode_encode(mfname), + myfile = codecs.open(_unicode_encode(mfname, + encoding=_fs_encoding, errors='strict'), mode='r', encoding='utf_8', errors='replace') lines = myfile.readlines() myfile.close() |