summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-04-22 01:21:27 (GMT)
committerBrett Cannon <brett@python.org>2012-04-22 01:21:27 (GMT)
commit0d05a7698b3c66579c87b2bfc5b9e043c1064a93 (patch)
tree85d420084946320d5aaa9119e0e90963bffd8d1c /Lib/importlib
parentcb165db3a3ef1cf327b6591a3747fcb21aa37e6e (diff)
downloadcpython-0d05a7698b3c66579c87b2bfc5b9e043c1064a93.zip
cpython-0d05a7698b3c66579c87b2bfc5b9e043c1064a93.tar.gz
cpython-0d05a7698b3c66579c87b2bfc5b9e043c1064a93.tar.bz2
Have importlib look for pre-existing path separators when joining
paths.
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/_bootstrap.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index fb233cb..8ed7687 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -63,8 +63,16 @@ def _r_long(int_bytes):
def _path_join(*args):
"""Replacement for os.path.join()."""
- sep = path_sep if args[0][-1:] not in path_separators else args[0][-1]
- return sep.join(x[:-len(path_sep)] if x.endswith(path_sep) else x
+ if len(path_separators) == 1:
+ sep = path_sep
+ else:
+ for c in reversed(args[0]):
+ if x in path_separators:
+ sep = x
+ break
+ else:
+ sep = path_sep
+ return sep.join(x[:-len(sep)] if x.endswith(sep) else x
for x in args if x)