From dfd2101969942f3a48c995e78c15ee69c4600ecd Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 4 Aug 2009 18:09:46 +0000 Subject: Avoid UnicodeEncodeError in writemsg(). Thanks to Markos Chandras for reporting. svn path=/main/trunk/; revision=13900 --- pym/portage/util.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'pym') 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() -- cgit v1.2.3-1-g7c22