Skip to content

Commit fe75b62

Browse files
tomasfariasrhettinger
authored andcommitted
bpo-38807: Add os.PathLike to exception message raised by _check_arg_types (#17160)
1 parent 02b8051 commit fe75b62

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Lib/genericpath.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def _check_arg_types(funcname, *args):
149149
elif isinstance(s, bytes):
150150
hasbytes = True
151151
else:
152-
raise TypeError('%s() argument must be str or bytes, not %r' %
153-
(funcname, s.__class__.__name__)) from None
152+
raise TypeError(f'{funcname}() argument must be str, bytes, or '
153+
f'os.PathLike object, not {s.__class__.__name__!r}') from None
154154
if hasstr and hasbytes:
155155
raise TypeError("Can't mix strings and bytes in path components") from None
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update :exc:`TypeError` messages for :meth:`os.path.join` to include :class:`os.PathLike` objects as acceptable input types.

0 commit comments

Comments
 (0)