summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-08-07 08:47:47 +0000
committerZac Medico <zmedico@gentoo.org>2009-08-07 08:47:47 +0000
commit54669f5635cbb75ab569820dc22bdacb143e203e (patch)
tree99da1865dc6e3197b88416fee49984376f40de73
parentcfeb7f4273946bb5f67dcf0b9de403bd20fa1875 (diff)
downloadportage-54669f5635cbb75ab569820dc22bdacb143e203e.tar.gz
portage-54669f5635cbb75ab569820dc22bdacb143e203e.tar.bz2
portage-54669f5635cbb75ab569820dc22bdacb143e203e.zip
In config.__setitem__(), convert keys/values to unicode in order to avoid
potential UnicodeDecodeError exceptions later. svn path=/main/trunk/; revision=13946
-rw-r--r--pym/portage/__init__.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 276f8852d..af908f041 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -3197,8 +3197,15 @@ class config(object):
"set a value; will be thrown away at reset() time"
if not isinstance(myvalue, basestring):
raise ValueError("Invalid type being used as a value: '%s': '%s'" % (str(mykey),str(myvalue)))
+
+ # Avoid potential UnicodeDecodeError exceptions later.
+ if not isinstance(mykey, unicode):
+ mykey = unicode(mykey, encoding='utf_8', errors='replace')
+ if not isinstance(myvalue, unicode):
+ myvalue = unicode(myvalue, encoding='utf_8', errors='replace')
+
self.modifying()
- self.modifiedkeys += [mykey]
+ self.modifiedkeys.append(mykey)
self.configdict["env"][mykey]=myvalue
def environ(self):