Fix breakage in _unicode_encode() for non-string types.
authorZac Medico <zmedico@gentoo.org>
Mon, 21 Sep 2009 14:47:40 +0000 (14:47 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 21 Sep 2009 14:47:40 +0000 (14:47 -0000)
svn path=/main/trunk/; revision=14323

pym/portage/__init__.py

index e3fee8084214486b03b4e64c1c0ed222c24a37bf..fe696b6dc3a2b7a4c5ba279b89096c2321b2e7ae 100644 (file)
@@ -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