summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2009-09-21 17:03:17 +0000
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2009-09-21 17:03:17 +0000
commit1e41a53912fa53b74577752cbbad7cbdd4e2afef (patch)
tree76735564651e99efe7c166022f44cc8da0489a10
parent6f5dda26fffd5457f82ccb9bd12b2d1d0a42c970 (diff)
downloadportage-1e41a53912fa53b74577752cbbad7cbdd4e2afef.tar.gz
portage-1e41a53912fa53b74577752cbbad7cbdd4e2afef.tar.bz2
portage-1e41a53912fa53b74577752cbbad7cbdd4e2afef.zip
Support bytes in portage.util.normalize_path() with Python 3.
svn path=/main/trunk/; revision=14333
-rw-r--r--pym/portage/util.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/pym/portage/util.py b/pym/portage/util.py
index 5f1a42c2f..ab70fd5c4 100644
--- a/pym/portage/util.py
+++ b/pym/portage/util.py
@@ -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)