mirror of
https://github.com/python/cpython.git
synced 2025-07-16 07:45:20 +00:00
Issue #21883: os.path.join() and os.path.relpath() now raise a TypeError with
more helpful error message for unsupported or mismatched types of arguments.
This commit is contained in:
parent
385328bf76
commit
3deeeb0c39
8 changed files with 135 additions and 89 deletions
|
@ -50,20 +50,24 @@ def isabs(s):
|
|||
|
||||
|
||||
def join(s, *p):
|
||||
colon = _get_colon(s)
|
||||
path = s
|
||||
for t in p:
|
||||
if (not path) or isabs(t):
|
||||
path = t
|
||||
continue
|
||||
if t[:1] == colon:
|
||||
t = t[1:]
|
||||
if colon not in path:
|
||||
path = colon + path
|
||||
if path[-1:] != colon:
|
||||
path = path + colon
|
||||
path = path + t
|
||||
return path
|
||||
try:
|
||||
colon = _get_colon(s)
|
||||
path = s
|
||||
for t in p:
|
||||
if (not path) or isabs(t):
|
||||
path = t
|
||||
continue
|
||||
if t[:1] == colon:
|
||||
t = t[1:]
|
||||
if colon not in path:
|
||||
path = colon + path
|
||||
if path[-1:] != colon:
|
||||
path = path + colon
|
||||
path = path + t
|
||||
return path
|
||||
except (TypeError, AttributeError, BytesWarning):
|
||||
genericpath._check_arg_types('join', s, *p)
|
||||
raise
|
||||
|
||||
|
||||
def split(s):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue