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): elif isinstance(s, bytes):
hasbytes = True hasbytes = True
else: else:
raise TypeError('%s() argument must be str or bytes, not %r' % raise TypeError(f'{funcname}() argument must be str, bytes, or '
(funcname, s.__class__.__name__)) from None f'os.PathLike object, not {s.__class__.__name__!r}') from None
if hasstr and hasbytes: if hasstr and hasbytes:
raise TypeError("Can't mix strings and bytes in path components") from None 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.