]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38807: Add os.PathLike to exception message raised by _check_arg_types (#17160)
authorTomás Farías <tomasfariassantana@gmail.com>
Tue, 19 Nov 2019 05:54:00 +0000 (21:54 -0800)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>
Tue, 19 Nov 2019 05:54:00 +0000 (21:54 -0800)
Lib/genericpath.py
Misc/NEWS.d/next/Library/2019-11-15-09-30-29.bpo-38807.PsmRog.rst [new file with mode: 0644]

index db11f67d54cc2f8b468294da231ee37c7781362e..ce36451a3af01cba7628ad7893183dd19283761d 100644 (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
diff --git a/Misc/NEWS.d/next/Library/2019-11-15-09-30-29.bpo-38807.PsmRog.rst b/Misc/NEWS.d/next/Library/2019-11-15-09-30-29.bpo-38807.PsmRog.rst
new file mode 100644 (file)
index 0000000..2bd7e3d
--- /dev/null
@@ -0,0 +1 @@
+Update :exc:`TypeError` messages for :meth:`os.path.join` to include :class:`os.PathLike` objects as acceptable input types.
\ No newline at end of file