Convert paths to unicode when working with CONTENTS.
authorZac Medico <zmedico@gentoo.org>
Thu, 6 Aug 2009 08:25:23 +0000 (08:25 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 6 Aug 2009 08:25:23 +0000 (08:25 -0000)
svn path=/main/trunk/; revision=13930

pym/portage/dbapi/vartree.py

index c6374cdf97a24b5e225e76aa38d2fbe036100969..52d48a70fade7a61d0ed3d9fb65b8195590906cd 100644 (file)
@@ -1353,11 +1353,16 @@ class vardbapi(dbapi):
                if not hasattr(pkg, "getcontents"):
                        pkg = self._dblink(pkg)
                root = self.root
+               if not isinstance(root, unicode):
+                       root = unicode(root, encoding='utf_8', errors='replace')
                root_len = len(root) - 1
                new_contents = pkg.getcontents().copy()
                removed = 0
 
                for filename in paths:
+                       if not isinstance(filename, unicode):
+                               filename = unicode(filename, 
+                                       encoding='utf_8', errors='replace')
                        filename = normalize_path(filename)
                        if relative_paths:
                                relative_filename = filename
@@ -2530,6 +2535,14 @@ class dblink(object):
                        if the file is not owned by this package.
                """
 
+               if not isinstance(filename, unicode):
+                       filename = unicode(filename,
+                               encoding='utf_8', errors='replace')
+
+               if not isinstance(destroot, unicode):
+                       destroot = unicode(destroot,
+                               encoding='utf_8', errors='replace')
+
                destfile = normalize_path(
                        os.path.join(destroot, filename.lstrip(os.path.sep)))
 
@@ -2712,6 +2725,8 @@ class dblink(object):
                new_contents = self.getcontents().copy()
                old_contents = self._installed_instance.getcontents()
                for f in sorted(preserve_paths):
+                       if not isinstance(f, unicode):
+                               f = unicode(f, encoding='utf_8', errors='replace')
                        f_abs = os.path.join(root, f.lstrip(os.sep))
                        contents_entry = old_contents.get(f_abs)
                        if contents_entry is None:
@@ -3734,6 +3749,9 @@ class dblink(object):
                        mydest = join(destroot, offset, x)
                        # myrealdest is mydest without the $ROOT prefix (makes a difference if ROOT!="/")
                        myrealdest = join(sep, offset, x)
+                       if not isinstance(myrealdest, unicode):
+                               myrealdest = unicode(myrealdest,
+                                       encoding='utf_8', errors='replace')
                        # stat file once, test using S_* macros many times (faster that way)
                        mystat = os.lstat(mysrc)
                        mymode = mystat[stat.ST_MODE]