public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r13945 - main/trunk/pym/portage
@ 2009-08-07  8:31 Zac Medico (zmedico)
  0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2009-08-07  8:31 UTC (permalink / raw
  To: gentoo-commits

Author: zmedico
Date: 2009-08-07 08:31:39 +0000 (Fri, 07 Aug 2009)
New Revision: 13945

Modified:
   main/trunk/pym/portage/__init__.py
Log:
Convert environment variables to unicode inside the config constructor, in
order to avoid potential UnicodeDecodeError exceptions later.


Modified: main/trunk/pym/portage/__init__.py
===================================================================
--- main/trunk/pym/portage/__init__.py	2009-08-07 08:21:56 UTC (rev 13944)
+++ main/trunk/pym/portage/__init__.py	2009-08-07 08:31:39 UTC (rev 13945)
@@ -1519,8 +1519,18 @@
 			# backupenv is used for calculating incremental variables.
 			if env is None:
 				env = os.environ
-			self.backupenv = env.copy()
 
+			# Avoid potential UnicodeDecodeError exceptions later.
+			env_unicode = {}
+			for k, v in env.iteritems():
+				if not isinstance(k, unicode):
+					k = unicode(k, encoding='utf_8', errors='replace')
+				if not isinstance(v, unicode):
+					v = unicode(v, encoding='utf_8', errors='replace')
+				env_unicode[k] = v
+
+			self.backupenv = env_unicode
+
 			if env_d:
 				# Remove duplicate values so they don't override updated
 				# profile.env values later (profile.env is reloaded in each




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-08-07  8:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-07  8:31 [gentoo-commits] portage r13945 - 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