Bug #280460 - Fix UnicodeDecodeError in env_update() due to non-unicode
authorZac Medico <zmedico@gentoo.org>
Wed, 5 Aug 2009 18:07:45 +0000 (18:07 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 5 Aug 2009 18:07:45 +0000 (18:07 -0000)
strings from getconfig(). TODO: Make getconfig() return unicode.

svn path=/main/trunk/; revision=13921

pym/portage/__init__.py

index c17b0c6d5de08f1e6bae9213182350e7f479c11e..7b5d56048d04fb833f36d3300098e39362802960 100644 (file)
@@ -685,6 +685,18 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
                        # broken symlink or file removed by a concurrent process
                        writemsg("!!! File Not Found: '%s'\n" % file_path, noiselevel=-1)
                        continue
+
+               # TODO: Make getconfig() return unicode.
+               unicode_config = {}
+               for k, v in myconfig.iteritems():
+                       if not isinstance(k, unicode):
+                               k = unicode(k, encoding='utf8', errors='replace')
+                       if not isinstance(v, unicode):
+                               v = unicode(v, encoding='utf8', errors='replace')
+                       unicode_config[k] = v
+               myconfig = unicode_config
+               del unicode_config
+
                config_list.append(myconfig)
                if "SPACE_SEPARATED" in myconfig:
                        space_separated.update(myconfig["SPACE_SEPARATED"].split())