From: Zac Medico Date: Mon, 21 Sep 2009 14:47:40 +0000 (-0000) Subject: Fix breakage in _unicode_encode() for non-string types. X-Git-Tag: v2.2_rc42~79 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e0bc361e32fcc4340bf31289f95e72cfa9ca1ed1;p=portage.git Fix breakage in _unicode_encode() for non-string types. svn path=/main/trunk/; revision=14323 --- diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index e3fee8084..fe696b6dc 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -142,7 +142,10 @@ if _encodings['merge'] is None: def _unicode_encode(s, encoding=_encodings['content'], errors='backslashreplace'): - if not isinstance(s, bytes): + if sys.hexversion >= 0x3000000: + if isinstance(s, str): + s = s.encode(encoding, errors) + elif isinstance(s, unicode): s = s.encode(encoding, errors) return s