From: "Zac Medico (zmedico)" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] portage r14073 - main/trunk/pym/portage
Date: Mon, 17 Aug 2009 00:25:59 +0000 [thread overview]
Message-ID: <E1Mcq2x-0002xw-Il@stork.gentoo.org> (raw)
Author: zmedico
Date: 2009-08-17 00:25:58 +0000 (Mon, 17 Aug 2009)
New Revision: 14073
Modified:
main/trunk/pym/portage/__init__.py
Log:
When _unicode_func_wrapper() decodes a string in a returned list (typically
from os.listdir), discard values with invalid encoding. This insures that
all names returned from all os.listdir() calls are valid.
Modified: main/trunk/pym/portage/__init__.py
===================================================================
--- main/trunk/pym/portage/__init__.py 2009-08-17 00:15:11 UTC (rev 14072)
+++ main/trunk/pym/portage/__init__.py 2009-08-17 00:25:58 UTC (rev 14073)
@@ -168,12 +168,21 @@
if isinstance(rval, (basestring, list, tuple)):
if isinstance(rval, basestring):
rval = _unicode_decode(rval, encoding=encoding)
- elif isinstance(rval, list):
- rval = [_unicode_decode(x, encoding=encoding) for x in rval]
- elif isinstance(rval, tuple):
- rval = tuple(_unicode_decode(x, encoding=encoding) \
- for x in rval)
+ else:
+ decoded_rval = []
+ for x in rval:
+ try:
+ x = _unicode_decode(x, encoding=encoding, errors='strict')
+ except UnicodeDecodeError:
+ pass
+ else:
+ decoded_rval.append(x)
+ if isinstance(rval, tuple):
+ rval = tuple(decoded_rval)
+ else:
+ rval = decoded_rval
+
return rval
class _unicode_module_wrapper(object):
reply other threads:[~2009-08-17 0:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1Mcq2x-0002xw-Il@stork.gentoo.org \
--to=zmedico@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox