bpo-38807: Add os.PathLike to exception message raised by _check_arg_types (#17160)

This commit is contained in:
Tomás Farías 2019-11-18 21:54:00 -08:00 committed by Raymond Hettinger
parent 02b8051a5e
commit fe75b62575
2 changed files with 3 additions and 2 deletions

View file

@ -149,7 +149,7 @@ def _check_arg_types(funcname, *args):
elif isinstance(s, bytes):
hasbytes = True
else:
raise TypeError('%s() argument must be str or bytes, not %r' %
(funcname, s.__class__.__name__)) from None
raise TypeError(f'{funcname}() argument must be str, bytes, or '
f'os.PathLike object, not {s.__class__.__name__!r}') from None
if hasstr and hasbytes:
raise TypeError("Can't mix strings and bytes in path components") from None

View file

@ -0,0 +1 @@
Update :exc:`TypeError` messages for :meth:`os.path.join` to include :class:`os.PathLike` objects as acceptable input types.