* [gentoo-commits] portage r14073 - main/trunk/pym/portage
@ 2009-08-17 0:25 Zac Medico (zmedico)
0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2009-08-17 0:25 UTC (permalink / raw
To: gentoo-commits
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):
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-08-17 0:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-17 0:25 [gentoo-commits] portage r14073 - main/trunk/pym/portage Zac Medico (zmedico)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox