Commit a69c80c5 authored by Brett Cannon's avatar Brett Cannon

Issue #13959: Continue to try to accomodate altsep in importlib by not

ignoring altsep if it already exists on a path when doing a join.
parent b4a9a40f
...@@ -61,12 +61,16 @@ def _r_long(int_bytes): ...@@ -61,12 +61,16 @@ def _r_long(int_bytes):
return x return x
# XXX Optimize for single-separator OSs by having two versions of this function def _path_join(*path_parts):
# and choosing in _setup().
def _path_join(*args):
"""Replacement for os.path.join().""" """Replacement for os.path.join()."""
return path_sep.join(x[:-len(path_sep)] if x.endswith(path_sep) else x new_parts = []
for x in args if x) for part in path_parts:
if not part:
continue
new_parts.append(part)
if part[-1] not in path_separators:
new_parts.append(path_sep)
return ''.join(new_parts[:-1]) # Drop superfluous path separator.
def _path_split(path): def _path_split(path):
...@@ -1178,6 +1182,8 @@ def _setup(sys_module, _imp_module): ...@@ -1178,6 +1182,8 @@ def _setup(sys_module, _imp_module):
os_details = ('posix', ['/']), ('nt', ['\\', '/']), ('os2', ['\\', '/']) os_details = ('posix', ['/']), ('nt', ['\\', '/']), ('os2', ['\\', '/'])
for builtin_os, path_separators in os_details: for builtin_os, path_separators in os_details:
# Assumption made in _path_join()
assert all(len(sep) == 1 for sep in path_separators)
path_sep = path_separators[0] path_sep = path_separators[0]
if builtin_os in sys.modules: if builtin_os in sys.modules:
os_module = sys.modules[builtin_os] os_module = sys.modules[builtin_os]
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment