From: Zac Medico Date: Tue, 4 Aug 2009 18:09:46 +0000 (-0000) Subject: Avoid UnicodeEncodeError in writemsg(). Thanks to Markos Chandras X-Git-Tag: v2.2_rc36~17 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dfd2101969942f3a48c995e78c15ee69c4600ecd;p=portage.git Avoid UnicodeEncodeError in writemsg(). Thanks to Markos Chandras for reporting. svn path=/main/trunk/; revision=13900 --- diff --git a/pym/portage/util.py b/pym/portage/util.py index 49eec6492..f1bff1d40 100644 --- a/pym/portage/util.py +++ b/pym/portage/util.py @@ -56,6 +56,9 @@ def writemsg(mystr,noiselevel=0,fd=None): if fd is None: fd = sys.stderr if noiselevel <= noiselimit: + if sys.hexversion < 0x3000000 and isinstance(mystr, unicode): + # avoid potential UnicodeEncodeError + mystr = mystr.encode('utf_8', 'replace') fd.write(mystr) fd.flush()