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

Author: zmedico
Date: 2009-08-07 08:47:47 +0000 (Fri, 07 Aug 2009)
New Revision: 13946

Modified:
   main/trunk/pym/portage/__init__.py
Log:
In config.__setitem__(), convert keys/values to unicode 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:31:39 UTC (rev 13945)
+++ main/trunk/pym/portage/__init__.py	2009-08-07 08:47:47 UTC (rev 13946)
@@ -3197,8 +3197,15 @@
 		"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):




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

only message in thread, other threads:[~2009-08-07  8:47 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:47 [gentoo-commits] portage r13946 - 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