[Python-checkins] cpython: Have importlib look for pre-existing path separators when joining
brett.cannon
python-checkins at python.org
Sun Apr 22 03:22:01 CEST 2012
http://hg.python.org/cpython/rev/b8cd8dd7006a
changeset: 76459:b8cd8dd7006a
parent: 76456:8fc44e3a6bfe
user: Brett Cannon <brett at python.org>
date: Sat Apr 21 21:21:27 2012 -0400
summary:
Have importlib look for pre-existing path separators when joining
paths.
files:
Lib/importlib/_bootstrap.py | 12 ++++++++++--
Python/importlib.h | Bin
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -63,8 +63,16 @@
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)
diff --git a/Python/importlib.h b/Python/importlib.h
index c48b5507699c679b7353d7e96ca9f4965da97c5b..115a5a9f7c0341a34b9f77989fcf0c2c82dcd95b
GIT binary patch
[stripped]
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list