mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Have importlib look for pre-existing path separators when joining
paths.
This commit is contained in:
parent
cb165db3a3
commit
0d05a7698b
2 changed files with 3023 additions and 3011 deletions
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue