diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-08-14 23:25:33 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-08-14 23:25:33 +0000 |
commit | 71de16243fbe4effec21d2c6e7801011b7c04612 (patch) | |
tree | 84b5ff3112f878fb471111f96ce539bbbc7b4231 | |
parent | 1692fbaa882e81ba6e4c5d6622876b923c050f1d (diff) | |
download | portage-71de16243fbe4effec21d2c6e7801011b7c04612.tar.gz portage-71de16243fbe4effec21d2c6e7801011b7c04612.tar.bz2 portage-71de16243fbe4effec21d2c6e7801011b7c04612.zip |
Handle UnicodeDecodeError for os.walk() inside digestcheck().
svn path=/main/trunk/; revision=14054
-rw-r--r-- | pym/portage/__init__.py | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 4ce64eaa5..8f59a3978 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -5293,12 +5293,37 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0): filesdir = os.path.join(pkgdir, "files") for parent, dirs, files in os.walk(filesdir): - parent = _unicode_decode(parent) + try: + parent = _unicode_decode(parent, + encoding=_fs_encoding, errors='strict') + except UnicodeDecodeError: + parent = _unicode_decode(parent, + encoding=_fs_encoding, errors='replace') + writemsg("!!! Path contains invalid " + \ + "character(s) for encoding '%s': '%s'" \ + % (_fs_encoding, parent), noiselevel=-1) + if strict: + return 0 + continue for d in dirs: if d.startswith(".") or d == "CVS": dirs.remove(d) for f in files: - f = _unicode_decode(f) + try: + f = _unicode_decode(f, + encoding=_fs_encoding, errors='strict') + except UnicodeDecodeError: + f = _unicode_decode(f, + encoding=_fs_encoding, errors='replace') + if f.startswith("."): + continue + f = os.path.join(parent, f)[len(filesdir) + 1:] + writemsg("!!! File name contains invalid " + \ + "character(s) for encoding '%s': '%s'" \ + % (_fs_encoding, f), noiselevel=-1) + if strict: + return 0 + continue if f.startswith("."): continue f = os.path.join(parent, f)[len(filesdir) + 1:] |