changeset: 76472:4e853913054c parent: 76468:4a12e8d32ac6 user: Brett Cannon date: Sun Apr 22 11:45:07 2012 -0400 files: Lib/importlib/_bootstrap.py Python/importlib.h description: 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. diff -r 4a12e8d32ac6 -r 4e853913054c Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py Sun Apr 22 02:08:59 2012 -0400 +++ b/Lib/importlib/_bootstrap.py Sun Apr 22 11:45:07 2012 -0400 @@ -61,12 +61,16 @@ return x -# XXX Optimize for single-separator OSs by having two versions of this function -# and choosing in _setup(). -def _path_join(*args): +def _path_join(*path_parts): """Replacement for os.path.join().""" - return path_sep.join(x[:-len(path_sep)] if x.endswith(path_sep) else x - for x in args if x) + new_parts = [] + 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): @@ -1178,6 +1182,8 @@ os_details = ('posix', ['/']), ('nt', ['\\', '/']), ('os2', ['\\', '/']) 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] if builtin_os in sys.modules: os_module = sys.modules[builtin_os] diff -r 4a12e8d32ac6 -r 4e853913054c Python/importlib.h Binary file Python/importlib.h has changed