getbinpkg: fix old binhost protocol for python3
authorZac Medico <zmedico@gentoo.org>
Fri, 9 Sep 2011 04:05:58 +0000 (21:05 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 9 Sep 2011 04:05:58 +0000 (21:05 -0700)
This will fix bug #382233.

pym/portage/getbinpkg.py

index 3e5867223b52952b4c5d94f67a631b940e31bd2f..579a46f9b7eb9a5a6c316aa47012d31cfa185280 100644 (file)
@@ -8,7 +8,9 @@ from portage.localization import _
 import portage
 from portage import os
 from portage import _encodings
+from portage import _unicode_decode
 from portage import _unicode_encode
+from _emerge.Package import _all_metadata_keys
 
 import sys
 import socket
@@ -65,8 +67,15 @@ def make_metadata_dict(data):
        myid,myglob = data
        
        mydict = {}
-       for x in portage.xpak.getindex_mem(myid):
-               mydict[x] = portage.xpak.getitem(data,x)
+       for k_bytes in portage.xpak.getindex_mem(myid):
+               k = _unicode_decode(k_bytes,
+                       encoding=_encodings['repo.content'], errors='replace')
+               if k not in _all_metadata_keys and \
+                       k != "CATEGORY":
+                       continue
+               v = _unicode_decode(portage.xpak.getitem(data, k_bytes),
+                       encoding=_encodings['repo.content'], errors='replace')
+               mydict[k] = v
 
        return mydict
 
@@ -354,7 +363,7 @@ def dir_get_list(baseurl,conn=None):
                
                if page:
                        parser = ParseLinks()
-                       parser.feed(page)
+                       parser.feed(_unicode_decode(page))
                        del page
                        listing = parser.get_anchors()
                else: