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:
Serhiy Storchaka 2014-10-04 14:58:43 +03:00
parent 385328bf76
commit 3deeeb0c39
8 changed files with 135 additions and 89 deletions

View file

@ -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):