Make portage.listdir() and dbapi.cp_list() return unicode.
authorZac Medico <zmedico@gentoo.org>
Mon, 20 Jul 2009 20:24:24 +0000 (20:24 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 20 Jul 2009 20:24:24 +0000 (20:24 -0000)
svn path=/main/trunk/; revision=13839

pym/portage/__init__.py
pym/portage/dbapi/porttree.py
pym/portage/dbapi/vartree.py

index d78491c4d3192e499438d43f6f2c20f885f881e1..3a969bbce81e892da146952aec92d0c01d2c136a 100644 (file)
@@ -246,6 +246,8 @@ def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, followSymli
                        raise portage.exception.PermissionDenied(mypath)
                ftype = []
                for x in list:
+                       if not isinstance(x, unicode):
+                               x = unicode(x, errors='replace')
                        try:
                                if followSymlinks:
                                        pathstat = os.stat(mypath+"/"+x)
index e29377f72304c139b3136081fd0d36038ee6dd9a..1fd5938113adb539d0d4ff7e507f0b0101c9fe88 100644 (file)
@@ -873,6 +873,8 @@ class portdbapi(dbapi):
                        except OSError:
                                continue
                        for x in file_list:
+                               if not isinstance(x, unicode):
+                                       x = unicode(x, errors='replace')
 
                                pf = None
                                if glep55:
index 486439718445eb6896f73c0a3c1e51014729e32f..d92bdf9efb1740558865d1f9273804671eeb5560 100644 (file)
@@ -894,6 +894,8 @@ class vardbapi(dbapi):
 
                returnme = []
                for x in dir_list:
+                       if not isinstance(x, unicode):
+                               x = unicode(x, errors='replace')
                        if self._excluded_dirs.match(x) is not None:
                                continue
                        ps = pkgsplit(x)
@@ -925,7 +927,8 @@ class vardbapi(dbapi):
                else:
                        def listdir(p, **kwargs):
                                try:
-                                       return [x for x in os.listdir(p) \
+                                       return [isinstance(x, unicode) and x or \
+                                               unicode(x, errors='replace') for x in os.listdir(p) \
                                                if os.path.isdir(os.path.join(p, x))]
                                except EnvironmentError, e:
                                        if e.errno == PermissionDenied.errno: