Support bytes in portage.util.normalize_path() with Python 3.
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Mon, 21 Sep 2009 17:03:17 +0000 (17:03 -0000)
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Mon, 21 Sep 2009 17:03:17 +0000 (17:03 -0000)
svn path=/main/trunk/; revision=14333

pym/portage/util.py

index 5f1a42c2f13e6ddaefcbf2c0608d24d049b6adeb..ab70fd5c47a7eab4faab2e5cca3efac111df29f2 100644 (file)
@@ -104,9 +104,14 @@ def normalize_path(mypath):
        We dislike this behavior so we create our own normpath func
        to fix it.
        """
-       if mypath.startswith(os.path.sep):
+       if sys.hexversion >= 0x3000000 and isinstance(mypath, bytes):
+               path_sep = os.path.sep.encode()
+       else:
+               path_sep = os.path.sep
+
+       if mypath.startswith(path_sep):
                # posixpath.normpath collapses 3 or more leading slashes to just 1.
-               return os.path.normpath(2*os.path.sep + mypath)
+               return os.path.normpath(2*path_sep + mypath)
        else:
                return os.path.normpath(mypath)